Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Namespace' object has no attribute 'strict' #5439

Closed
davidemoro opened this issue Jun 12, 2019 · 3 comments
Closed

AttributeError: 'Namespace' object has no attribute 'strict' #5439

davidemoro opened this issue Jun 12, 2019 · 3 comments
Labels
type: question general question, might be closed after 2 weeks of inactivity

Comments

@davidemoro
Copy link

Hi, starting from pytest==4.6.3 version I get an attribute error for

>>> self.config.option.strict
*** AttributeError: 'Namespace' object has no attribute 'strict'

and:

>>> self.session.config.addmetadatavalue_line
*** AttributeError: 'Config' object has no attribute 'addmetadatavalue_line'

How to reproduce:

  • be sure you have the latest version of davidemoro/pytest-play from docker hub (at this time of writing tag 61cdbe838352b2065d072cbf790d4ad5cbfd333d on https://cloud.docker.com/repository/docker/davidemoro/pytest-play/general) shipped with pytest 4.6.3
  • create an empty folder (e.g., project) containing a test_example.yml and enter inside this directory
  • run docker run --rm -it -v $(pwd):/src davidemoro/pytest-play

test_example.yml contents:

---
markers:
  - marker1
  - marker2
---
- provider: python
  type: assert
  expression: "1"

Pytest output:

$ docker run --rm -it -v $(pwd):/src davidemoro/pytest-play
========================================================= test session starts =========================================================
platform linux -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0
Using --randomly-seed=1560327758
rootdir: /src
plugins: forked-1.0.2, pypom-navigation-2.0.3, metadata-1.8.0, html-1.20.0, testrail-2.3.3, bdd-3.1.0, xdist-1.28.0, repeat-0.8.0, randomly-3.0.0, splinter-2.0.1, variables-1.7.1, play-2.3.0
collected 0 items / 1 errors                                                                                                          

=============================================================== ERRORS ================================================================
_____________________________________ ERROR collecting test_autoexecute_yml_keywords_skipped.yml ______________________________________
/usr/local/lib/python3.7/site-packages/pytest_play/plugin.py:109: in collect
    self._add_markers(item, markers)
/usr/local/lib/python3.7/site-packages/pytest_play/plugin.py:68: in _add_markers
    if self.config.option.strict:
E   AttributeError: 'Namespace' object has no attribute 'strict'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================= 1 error in 0.94 seconds =======================================================

Pip freeze:

apipkg==1.5
apiritif==0.8.1
Appium-Python-Client==0.44
astunparse==1.6.2
atomicwrites==1.3.0
attrs==19.1.0
boto3==1.9.166
botocore==1.12.166
bzt==1.13.7
cassandra-driver==3.18.0
certifi==2019.3.9
chardet==3.0.4
colander==1.7.0
colorama==0.4.1
colorlog==4.0.2
cssselect==1.0.3
decorator==4.4.0
docutils==0.14
EasyProcess==0.2.7
execnet==1.6.0
fuzzyset==0.0.19
gevent==1.4.0
glob2==0.7
greenlet==0.4.15
hdrpy==0.3.3
idna==2.8
importlib-metadata==0.17
ipaddress==1.0.22
iso8601==0.1.12
Jinja2==2.10.1
jmespath==0.9.4
jsonpath-rw==1.4.0
lxml==4.3.4
Mako==1.0.12
MarkupSafe==1.1.1
more-itertools==7.0.0
mysqlclient==1.4.2.post1
nose==1.3.7
numpy==1.16.4
packaging==19.0
paho-mqtt==1.4.0
parametrizer==0.0.3
parse==1.12.0
parse-type==0.4.2
play-cassandra==0.0.4
play-dynamodb==0.0.2
play-mqtt==0.0.5
play-requests==0.0.5
play-selenium==0.0.2
play-sql==0.0.3
play-websocket==0.0.2
pluggy==0.12.0
ply==3.11
progressbar33==2.4
psutil==5.6.3
psycopg2-binary==2.8.2
py==1.8.0
pyparsing==2.4.0
PyPOM==2.2.0
pypom-form==0.3.1
pytest==4.6.3
pytest-bdd==3.1.0
pytest-forked==1.0.2
pytest-html==1.20.0
pytest-metadata==1.8.0
pytest-play==2.3.0
pytest-pypom-navigation==2.0.3
pytest-randomly==3.0.0
pytest-repeat==0.8.0
pytest-splinter==2.0.1
pytest-testrail==2.3.3
pytest-variables==1.7.1
pytest-xdist==1.28.0
python-dateutil==2.8.0
python-Levenshtein==0.12.0
PyVirtualDisplay==0.2.3
PyYAML==5.1.1
requests==2.22.0
RestrictedPython==4.0
s3transfer==0.2.1
selenium==3.141.0
simplejson==3.16.0
six==1.12.0
splinter==0.10.0
SQLAlchemy==1.3.4
statsd==3.3.0
terminaltables==3.1.0
texttable==1.6.1
translationstring==1.3
unicodecsv==0.14.1
urllib3==1.25.3
urwid==2.0.1
wcwidth==0.1.7
websocket-client==0.56.0
zipp==0.5.1
zope.component==4.5
zope.deferredimport==4.3
zope.deprecation==4.4.0
zope.dottedname==4.3
zope.event==4.4
zope.hookable==4.2.0
zope.interface==4.6.0
zope.proxy==4.3.1

Does the strict option was deprecated and the addmetadatavalue_line method too?
The problem is located here:

Thanks in advance!

@nicoddemus
Copy link
Member

Hi @davidemoro,

The internal strict option has been renamed to strict_markers, so using self.config.option.strict_markers or self.config.getoption("strict_markers") should work.

Not sure about addmetadatavalue_line though, are you sure it comes from pytest? A GitHub search shows that only pytest-play uses it, trying to register a marker, in which case it should be addinivalue_line: https://docs.pytest.org/en/latest/mark.html#registering-marks.

@nicoddemus nicoddemus added the type: question general question, might be closed after 2 weeks of inactivity label Jun 12, 2019
@nicoddemus
Copy link
Member

Hmm I noticed that master actually has the correct code.

Btw you should not check for strict_markers in order to register the markers using addinivalue_line, better to just always register them regardless of the option.

@davidemoro
Copy link
Author

Hi @nicoddemus,

thanks! Solved in next pytest-play version on its way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants