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

collection fails when jsonschema is imported (DegenerateFiles) #9335

Open
4 tasks done
KotlinIsland opened this issue Nov 24, 2021 · 2 comments
Open
4 tasks done

collection fails when jsonschema is imported (DegenerateFiles) #9335

KotlinIsland opened this issue Nov 24, 2021 · 2 comments
Labels
topic: collection related to the collection phase type: bug problem that needs to be addressed

Comments

@KotlinIsland
Copy link

KotlinIsland commented Nov 24, 2021

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

Description

When I run pytest it fails to collect when the python file is importing jsonschema, failures seem to happen for a couple of reasons:

TypeError: DegenerateFiles.Path.open() got an unexpected keyword argument 'encoding'
>pytest b.py
========================================================================================================== test session starts ===========================================================================================================
platform win32 -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: C:\test_project, configfile: pyproject.toml
collected 0 items / 1 error                                                                                                                                                                                                               

================================================================================================================= ERRORS ================================================================================================================= 
_________________________________________________________________________________________________________ ERROR collecting b.py __________________________________________________________________________________________________________ 
b.py:1: in <module>
    import jsonschema
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
venv\lib\site-packages\_pytest\assertion\rewrite.py:170: in exec_module
    exec(co, module.__dict__)
venv\lib\site-packages\jsonschema\__init__.py:29: in <module>
    from jsonschema.validators import (
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
venv\lib\site-packages\_pytest\assertion\rewrite.py:170: in exec_module
    exec(co, module.__dict__)
venv\lib\site-packages\jsonschema\validators.py:349: in <module>
    meta_schema=_utils.load_schema("draft3"),
venv\lib\site-packages\jsonschema\_utils.py:61: in load_schema
    data = path.read_text(encoding="utf-8")
..\..\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py:378: in read_text
    with self.open(encoding=encoding) as strm:
E   TypeError: DegenerateFiles.Path.open() got an unexpected keyword argument 'encoding'
======================================================================================================== short test summary info ========================================================================================================= 
ERROR b.py - TypeError: DegenerateFiles.Path.open() got an unexpected keyword argument 'encoding'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
============================================================================================================ 1 error in 0.83s ============================================================================================================ 
AttributeError: module 'idna' has no attribute 'IDNAError'
> pytest b.py
========================================================================================================== test session starts =========================================================================================================== 
platform win32 -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: C:\test_project
collected 0 items / 1 error                                                                                                                                                                                                                

================================================================================================================= ERRORS ================================================================================================================= 
_________________________________________________________________________________________________________ ERROR collecting b.py __________________________________________________________________________________________________________ 
b.py:1: in <module>
    import jsonschema
venv\lib\site-packages\jsonschema\__init__.py:12: in <module>
    from jsonschema._format import (
venv\lib\site-packages\jsonschema\_format.py:249: in <module>
    raises=(idna.IDNAError, UnicodeError),
E   AttributeError: module 'idna' has no attribute 'IDNAError'
======================================================================================================== short test summary info ========================================================================================================= 
ERROR b.py - AttributeError: module 'idna' has no attribute 'IDNAError'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
============================================================================================================ 1 error in 0.27s ============================================================================================================ 

And the same thing happens in my wsl interpreter

pip list

> pip list
Package      Version
------------ -------
atomicwrites 1.4.0
attrs        21.2.0
colorama     0.4.4
iniconfig    1.1.1
jsonschema   4.2.1
packaging    21.3
pip          21.3.1
pluggy       1.0.0
py           1.11.0
pyparsing    3.0.6
pyrsistent   0.18.0
pytest       6.2.5
setuptools   59.2.0
toml         0.10.2

pytest and operating system versions

pytest 6.2.5
Windows 10 1909 18363.1801
Seems to only happen in python 3.10 and 3.11, not 3.9

minimal example

import jsonschema
@Zac-HD Zac-HD added topic: collection related to the collection phase type: bug problem that needs to be addressed labels Nov 25, 2021
@The-Compiler
Copy link
Member

This seems related to #9174 perhaps?

@KotlinIsland
Copy link
Author

looks like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants