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

trouble running unit tests #4

Closed
nick-gorman opened this issue Nov 23, 2021 · 7 comments
Closed

trouble running unit tests #4

nick-gorman opened this issue Nov 23, 2021 · 7 comments

Comments

@nick-gorman
Copy link
Member

Hi @noah80, You reported having trouble running the unit tests, could you please provide some details?

  • Have you been able to install nempy and run any of the examples?
  • Have you been able to install the code as per the the instructions for development purposes? (https://github.com/UNSW-CEEM/nempy#installation)
  • What if any error messages are you receiving?
@noah80
Copy link

noah80 commented Nov 24, 2021

Hi,

I am using anaconda on windows. Cloned the repository with:
git clone ...
and created a conda virtual enviroment for testing.

Then I did the recommended install:
pip install e .[dev]
This went fine. Here is the end of the installation:


Successfully built nempy
Installing collected packages: pyparsing, zipp, webencodings, urllib3, six, pycparser, packaging, idna, charset-normalizer, requests, pywin32-ctypes, pytz, python-dateutil, Pygments, numpy, importlib-metadata, docutils, colorama, cffi, bleach, xmltodict, tqdm, toml, rfc3986, requests-toolbelt, readme-renderer, py, pluggy, pkginfo, pandas, more-itertools, mip, keyring, iniconfig, attrs, atomicwrites, twine, pytest, nempy, e
Successfully installed Pygments-2.10.0 atomicwrites-1.4.0 attrs-21.2.0 bleach-4.1.0 cffi-1.15.0 charset-normalizer-2.0.7 colorama-0.4.4 docutils-0.18.1 e-1.4.5 idna-3.3 importlib-metadata-4.8.2 iniconfig-1.1.1 keyring-23.2.1 mip-1.13.0 more-itertools-8.12.0 nempy-1.1.0 numpy-1.21.4 packaging-21.3 pandas-1.3.4 pkginfo-1.8.1 pluggy-0.13.1 py-1.11.0 pycparser-2.21 pyparsing-3.0.6 pytest-6.0.1 python-dateutil-2.8.2 pytz-2021.3 pywin32-ctypes-0.2.0 readme-renderer-30.0 requests-2.26.0 requests-toolbelt-0.9.1 rfc3986-1.5.0 six-1.16.0 toml-0.10.2 tqdm-4.62.3 twine-3.6.0 urllib3-1.26.7 webencodings-0.5.1 xmltodict-0.12.0 zipp-3.6.0


Looks good to me. Then the pytest thing failed:


(nempyenv) C:\work\nempy\nempy>python -m pytest
================================================= test session starts =================================================
platform win32 -- Python 3.10.0, pytest-6.0.1, py-1.11.0, pluggy-0.13.1
rootdir: C:\work\nempy\nempy, configfile: pytest.ini, testpaths: tests, nempy
collected 139 items / 16 errors / 123 selected

======================================================= ERRORS ========================================================
____________________________ ERROR collecting tests/test_historical_spot_market_inputs.py _____________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init_.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
____________________________ ERROR collecting tests/test_historical_spot_market_inputs.py _____________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
____________________________ ERROR collecting tests/test_interconnector_loss_functions.py _____________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
____________________________ ERROR collecting tests/test_interconnector_loss_functions.py _____________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
__________________________________ ERROR collecting tests/test_market_constraints.py __________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
__________________________________ ERROR collecting tests/test_market_constraints.py __________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
_______________________________________ ERROR collecting tests/test_markets.py ________________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
_______________________________________ ERROR collecting tests/test_markets.py ________________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
__________________________________ ERROR collecting tests/test_objective_function.py __________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
__________________________________ ERROR collecting tests/test_objective_function.py __________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
___________________________________ ERROR collecting tests/test_solver_interface.py ___________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
___________________________________ ERROR collecting tests/test_solver_interface.py ___________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
___________________________________ ERROR collecting tests/test_unit_constraints.py ___________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
___________________________________ ERROR collecting tests/test_unit_constraints.py ___________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
_____________________________________ ERROR collecting tests/test_variable_ids.py _____________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
_____________________________________ ERROR collecting tests/test_variable_ids.py _____________________________________
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\importlib_init
.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:161: in exec_module
source_stat, co = _rewrite_test(fn, self.config)
C:\Users\n.pflugradt.conda\envs\nempyenv\lib\site-packages_pytest\assertion\rewrite.py:360: in rewrite_test
co = compile(tree, fn
, "exec", dont_inherit=True)
E TypeError: required field "lineno" missing from alias
=============================================== short test summary info ===============================================
ERROR tests/test_historical_spot_market_inputs.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_historical_spot_market_inputs.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_interconnector_loss_functions.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_interconnector_loss_functions.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_market_constraints.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_market_constraints.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_markets.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_markets.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_objective_function.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_objective_function.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_solver_interface.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_solver_interface.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_unit_constraints.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_unit_constraints.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_variable_ids.py - TypeError: required field "lineno" missing from alias
ERROR tests/test_variable_ids.py - TypeError: required field "lineno" missing from alias
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 16 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================= 16 errors in 2.04s ==================================================

(nempyenv) C:\work\nempy\nempy>


Maybe a library is missing in the requirements?

@nick-gorman
Copy link
Member Author

Thanks @noah80,

Also, which version of python are you using?

Can you try updating to the newest version of pytest? currently nempy asks for 6.0.1 but maybe that doesn't work with all setups

@noah80
Copy link

noah80 commented Nov 25, 2021

Python 3.10.0

Pytest 6.0.1

Any ideas what I could try? As I said it's a fresh anaconda installation with a fresh virtual enviroment.

@nick-gorman
Copy link
Member Author

OK, yep so this is an issue specific to Python version 3.10, see stackoverflow below:

https://stackoverflow.com/questions/69528842/an-error-while-trying-to-execute-tests-on-python-3-10-with-pytest

Try updating pytest to 6.2.5 or above.

If that works, I'll update the nempy requirements so that pytest version 6.2.5 gets installed when you run pip install e .[dev]

@noah80
Copy link

noah80 commented Nov 29, 2021

Thanks! Now it works. So you need to add pytest 6.2.5 to your requirements?

Next problem:

(nempyenv) C:\work\nempy\nempy\examples>python all_features_example.py
Traceback (most recent call last):
File "C:\work\nempy\nempy\examples\all_features_example.py", line 5, in
import plotly.graph_objects as go
ModuleNotFoundError: No module named 'plotly'

Looks like plotly is missing in your requirements?

@nick-gorman
Copy link
Member Author

Excellent, yes, I'll update the requirements for the dev install.

I've created a separate issue with regards to the plotly error.

@nick-gorman
Copy link
Member Author

Updated dev install requirements in release v1.1.1

https://github.com/UNSW-CEEM/nempy/releases/tag/v1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants