Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Running tests with pipenv #25

Closed
amadeu01 opened this issue Jul 22, 2018 · 7 comments
Closed

Running tests with pipenv #25

amadeu01 opened this issue Jul 22, 2018 · 7 comments

Comments

@amadeu01
Copy link
Contributor

Traceback (most recent call last):
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/_pytest/config/__init__.py", line 55, in main
    config = _prepareconfig(args, plugins)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/_pytest/config/__init__.py", line 180, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/callers.py", line 196, in _multicall
    gen.send(outcome)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/callers.py", line 76, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/_pytest/config/__init__.py", line 612, in pytest_cmdline_parse
    self.parse(args)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/_pytest/config/__init__.py", line 777, in parse
    self._preparse(args, addopts=addopts)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/_pytest/config/__init__.py", line 739, in _preparse
    early_config=self, args=args, parser=self._parser
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/callers.py", line 201, in _multicall
    return outcome.get_result()
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/callers.py", line 76, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/pytest_django/plugin.py", line 246, in pytest_load_initial_conftests
    dj_settings.DATABASES
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/django/conf/__init__.py", line 106, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/amadeucavalcantefilho/Developer/perfil/api/api/settings.py", line 20, in <module>
    MONGO_URL = config('MONGO_URL')
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/decouple.py", line 197, in __call__
    return self.config(*args, **kwargs)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/decouple.py", line 85, in __call__
    return self.get(*args, **kwargs)
  File "/Users/amadeucavalcantefilho/.local/share/virtualenvs/perfil-hF4nD9Ih/lib/python3.7/site-packages/decouple.py", line 70, in get
    raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: MONGO_URL not found. Declare it as envvar or define a default value.

I don't know whether I have be running mongo while runing test.

@cuducos
Copy link
Contributor

cuducos commented Jul 22, 2018

I don't know whether I have be running mongo while runing test.

Long story short, yes, you should ; )

The core error message says the app expects the MongoDB URL in a envvar (or .env): decouple.UndefinedValueError: MONGO_URL not found..

@cuducos cuducos closed this as completed Jul 22, 2018
@amadeu01
Copy link
Contributor Author

It seems to be really silly a must have db setup just for run tests.
And, it should be explicitly written on the readme of the project that for running test we have to sepup the db.

@cuducos cuducos changed the title Running testes with pipenv Running tests with pipenv Jul 22, 2018
@cuducos
Copy link
Contributor

cuducos commented Jul 22, 2018

it should be explicitly written on the readme of the project that for running test we have to sepup the db.

Actually we have this line on the README.md: To run the API, you must copy the env-template to a .env file and add the MongoDB URL.

So if you follow the instructions you should not get the error you reported. Any ideas on how to make this line clearer?

@amadeu01
Copy link
Contributor Author

amadeu01 commented Jul 22, 2018

You could have one section dedicated to testing.
Like this /training-center/hades. You can look up for Rodando os testes com Docker.

So, you could have something like:

Running tests:

Requirements: having a MongoDB running locally....

@cuducos
Copy link
Contributor

cuducos commented Jul 22, 2018

Requirements: having a MongoDB running locally

IMHO this is kinda a simplistic. We have a section for Settings so what about: “In order to run tests you need to fully configure your instance as describer in the Settings section” – do you think this would make the instructions clearer?

@amadeu01
Copy link
Contributor Author

do you think this would make the instructions clearer?

Yeah. Thanks for your time!

Sorry any bothering

@cuducos cuducos reopened this Jul 22, 2018
@cuducos
Copy link
Contributor

cuducos commented Jul 22, 2018

Sorry any bothering

Contributing is never bothering ; )

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

No branches or pull requests

2 participants