pytest-dev / pytest-dev/pytest-bdd

Hooks not recognized when freezing with cx_Freeze

Open
#159 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
251
Avg merge
43m
Merged PRs (30d)
2

Description

This might be a pytest core issue as well, but I'm not sure - all my other plugins work fine, and I can't imagine pytest-bdd is the only one with custom hooks.

When running the tests frozen with cx_Freeze, after working around #158, I get:

____________________________________________ test_going_backforward ____________________________________________

request = <FixtureRequest for <Function 'test_going_backforward'>>

>   ???

tests/integration/features/test_features.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

feature = <pytest_bdd.feature.Feature object at 0x7f40b4716da0>
scenario = <pytest_bdd.feature.Scenario object at 0x7f40b4716e80>
request = <FixtureRequest for <Function 'test_going_backforward'>>, encoding = 'utf-8'

    def _execute_scenario(feature, scenario, request, encoding):
        """Execute the scenario.

        :param feature: Feature.
        :param scenario: Scenario.
        :param request: request.
        :param encoding: Encoding.
        """
>       request.config.hook.pytest_bdd_before_scenario(
            request=request,
            feature=feature,
            scenario=scenario,
        )
E       AttributeError: 'HookRelay' object has no attribute 'pytest_bdd_before_scenario'

.tox/unittests-frozen/lib/python3.4/site-packages/pytest_bdd/scenario.py:148: AttributeError

After commenting out all the hook calls, it works fine... I also tried the branch from #149 but that didn't help.

Any idea why this is happening?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the frozen test run with cx_Freeze and inspect tests/integration/features/test_features.py:41. Then trace _execute_scenario in pytest_bdd/scenario.py, especially the pytest_bdd_before_scenario hook call, and compare it with how hooks are registered in the frozen environment. Done means the frozen tests recognize the pytest-bdd hooks without commenting out hook calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.