Open-event-server: Switch tests to py.test from nose

Created on 5 Oct 2019  路  41Comments  路  Source: fossasia/open-event-server

nose is unmaintained and recommends to use nose2, unittest or pytest

pytest has fixture based dependency injection, and parametrization, and is generally better

good-first-issue help-wanted testing

All 41 comments

Tests you say? I'd be happy to take this on for you 馃挭

Made a PR at #6507. Please provide feedback.

@TJBANEY mentioned to work on it first. Also, this issue was not going to get solved by changing a line in requirements.txt

If it would be, we wouldn't have opened an issue for it, just did it ourselves

My bad. I forgot to add the commits to test files

My bad. I forgot to add the commits to test files

Did you just ignore my comments and @iamareebjamal comment on your PR and the following issue?
@souravsingh We follow a proper development workflow here at FOSSASIA and you just created a vague PR before dropping comment and also not to mention that change was of one line.

Please let @TJBANEY work on it as he commented first. If he has not worked on it for a week, you can proceed. We follow rules and ethics here

@kushthedude I had forgotten to add the commits for test files, which I added later(which you didn't care to see). And I worked on the issue, since the issue doesn't have any assignee. I apologize if this inconvenienced you.

We don't add assignees here. Please read the guidelines. We can't accept your PR unless @TJBANEY agrees to it or does not send a PR within a week.

Needless to say, reading and following community guidelines is the first step in contributing to any open source project. Not following them makes your PR unfit for consideration, complete or incomplete. And it is still incomplete

@iamareebjamal @souravsingh This is fine, It was late in my timezone when I started on it, so I didn't get much headway on it anyway 馃檪

Can I pick up on this? @iamareebjamal

Go ahead

Sorry for late response but I was successful in setting up the server, I tried running nosetests but they seem to be unsuccessful. Screenshot is attached for the same,

Stack :

ERROR: Test generation of hash for a key.

Traceback (most recent call last):
File "/home/aman/open-event-server/tests/all/unit/api/helpers/test_storage.py", line 53, in test_generate_hash
with patch('app.api.helpers.storage.get_settings') as get_settings:
File "/usr/lib/python3.6/unittest/mock.py", line 1231, in __enter__
self.target = self.getter()
File "/usr/lib/python3.6/unittest/mock.py", line 1401, in
getter = lambda: _importer(target)
File "/usr/lib/python3.6/unittest/mock.py", line 1084, in _importer
thing = __import__(import_path)
File "/home/aman/open-event-server/app/__init__.py", line 41, in
from app.api.helpers.scheduled_jobs import send_after_event_mail, send_event_fee_notification, \
File "/home/aman/open-event-server/app/api/helpers/scheduled_jobs.py", line 12, in
from app.api.helpers.query import get_upcoming_events, get_user_event_roles_by_role_name
File "/home/aman/open-event-server/app/api/helpers/query.py", line 6, in
from app.models.event import Event
File "/home/aman/open-event-server/app/models/event.py", line 19, in
from app.models.search import sync
File "/home/aman/open-event-server/app/models/search/sync.py", line 11, in
from app.models.search.event import SearchableEvent
File "/home/aman/open-event-server/app/models/search/event.py", line 2, in
from elasticsearch_dsl import DocType, Integer, Search, Text
ImportError: cannot import name 'DocType'

I looked on internet for the same and this issue seems to be coming from Elastic-search- DSL which can be averted by downgrading. [[LINK](https://github.com/sabricot/django-elasticsearch-dsl/issues/119)]

@iamareebjamal can I contact you over any mailing list or slack ??

Public communication is preferred

sure sir, I just wanted to shall I downgrade to get this DocType issue resolved??

Fetch latest code and install requirements again. It'll be fixed

Is this issue still not resolved? If it is open can i take it @iamareebjamal

Go ahead

Is this Issue still open ?

Green means open. Red means closed

Can I work on this?

Yes

@iamareebjamal I am newbie i don't know what exactly we need to do?Can you help me out?

@imrahul361 - Please read about py.test here https://docs.pytest.org/en/latest/

Hello,
Do I just have to change the commands from nose to pytest and do the same in necessary documents?
P.S: pytest command is working fine for all the current tests written when I run it locally.

No, you need to change the test style

No, you need to change the test style

By style, you mean to change the current tests code to a pytest version of them?
I have googled how to convert from nose to pytest and found this issue as a reference. The respective PR for the same was also successfully merged.

Yes

Hello,
I have made a change to my fork. Once can you please check it out.
https://github.com/diru1100/open-event-server/commit/c9569593b3f81d87d8129661e9fb864b397b0ef2

Send a PR

hi @iamareebjamal if its not resolved can i take it

Go ahead

hi @iamareebjamal if its not resolved can i take it

Go ahead

Found this while searching for help-wanted tags.

Please correct me if I'm wrong here, but doesn't Pytest prefer having all tests in one giant tests/ folder? I don't think that the conftest.py file will auto-apply itself to all of the subfolders, and I don't think Pytest's CLI has an option for recursively discovering tests in sub-folders. Maybe I just don't see the option.

In practice, I usually see all tests contained in a single folder as just very many .py files.

I noticed that you guys have integration and unit folders. If you go the route of merging all tests under a single folder, you'll probably want to use markers like @pytest.mark.integration and @pytest.mark.unit so that you can distinguish them for testing (i.e. pytest -v tests -m "not integration" or pytest -v tests -m "unit").

Do you think that merging all of the test files into a single tests folder is the right way to go here?

edit: Also, following the readme.md file didn't really work, because the instructions say to run pytest tests/, but there aren't any tests in that folder so there's nothing to do.

That's not true. We already have pytest setup now, we just want existing classic python tests to be converted to pytest format. It supports nesting directories just fine and we are currently using pytest runner only

Maybe I just missed something as I was following the directions for getting the local build setup, my mistake

@iamareebjamal Can I try on this issue?

Yes

a newbie in open source.Can I work on this issue??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CosmicCoder96 picture CosmicCoder96  路  3Comments

shubham-padia picture shubham-padia  路  4Comments

schedutron picture schedutron  路  4Comments

mariobehling picture mariobehling  路  4Comments

CosmicCoder96 picture CosmicCoder96  路  4Comments