pytest-bdd
pytest-bdd copied to clipboard
Please rename the types module
Given pytest-bdd is installed, if you type:
>>> import types
>>> types.__file__
'.....\\my_venv\\Lib\\site-packages\\pytest_bdd\\types.py'
But without pytest-bdd:
>>> import types
>>> types.__file__
'C:\\Program Files\\Python36\\lib\\types.py'
So types, which seems purely internal to the project, is overriding the core python types module.
Please provide more information:
- python version
- pytest_bdd version
- steps to reproduce the issue from scratch
In this example, I used Python 3.8 for the first and Python 3.6 for the second. I've just repeated the second test using Python 3.8 so that's the same either way. The problem description does reproduce it from scratch: in both cases, those are the only two commands from an interactive python interpreter.
The problem became particularly visible when I pip installed behave:
$ python -i
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import behave
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mgrazebrook\Desktop\murazur\home\src\reckon_digital\venv_syco_targeting\lib\site-packages\behave\__init__.py", line 20, in <module>
from behave.step_registry import * # pylint: disable=wildcard-import
File "C:\Users\mgrazebrook\Desktop\murazur\home\src\reckon_digital\venv_syco_targeting\lib\site-packages\behave\step_registry.py", line 9, in <module>
from behave.matchers import Match, get_matcher
File "C:\Users\mgrazebrook\Desktop\murazur\home\src\reckon_digital\venv_syco_targeting\lib\site-packages\behave\matchers.py", line 8, in <module>
import copy
File "C:\Users\mgrazebrook\AppData\Local\Programs\Python\Python38-32\lib\copy.py", line 111, in <module>
types.BuiltinFunctionType, type(Ellipsis), type(NotImplemented),
AttributeError: module 'types' has no attribute 'BuiltinFunctionType'
However for reasons I don't understand, when I uninstalled pytest-bdd and reinstalled it, the problem could no longer be reproduced! This makes no sense to me ...
$ python -i
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import behave
>>>
Off - topic:
I'm impressed by your fast response! Thanks.
I wanted to use a 'background' to set up a known test state of the 'here are a few rows to display' type and wanted to repeatedly use 'given' with different parameters. pytest-bdd disallows this, though gherkin seems to permit it. Why did you make that choice and what's the 'right' way to do this?
However for reasons I don't understand, when I uninstalled pytest-bdd and reinstalled it, the problem could no longer be reproduced! This makes no sense to me ...
That's the behavior I would've expected, and what I also see locally. To get the types
module from the pytest_bdd
package, you'd have to do from pytest_bdd import types
- that should never override the builtin types
one.
Did you by any chance change sys.path
or PYTHONPATH
in a way that it includes the pytest_bdd
folder?
I wanted to use a 'background' to set up a known test state of the 'here are a few rows to display' type and wanted to repeatedly use 'given' with different parameters. pytest-bdd disallows this, though gherkin seems to permit it. Why did you make that choice and what's the 'right' way to do this?
Sounds like #157?