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

Make Django assertions available outside of a TestCase class #709

Merged
merged 7 commits into from
Jan 13, 2020

Conversation

wgordon17
Copy link
Contributor

No description provided.

@wgordon17
Copy link
Contributor Author

This is my attempt at addressing some of the concerns in #232.

pytest_django/asserts.py Outdated Show resolved Hide resolved
Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good from a quick glance - thanks for picking it up.

docs/helpers.rst Outdated Show resolved Hide resolved
pytest_django/asserts.py Outdated Show resolved Hide resolved
pytest_django/asserts.py Outdated Show resolved Hide resolved
tests/test_asserts.py Outdated Show resolved Hide resolved
tests/test_asserts.py Outdated Show resolved Hide resolved
pytest_django/asserts.py Outdated Show resolved Hide resolved
@graingert
Copy link
Member

graingert commented Jun 16, 2019 via email

pytest_django/asserts.py Outdated Show resolved Hide resolved
@pakal
Copy link

pakal commented Jun 16, 2019

Approach looks straightforward and handy, thanks for this PR :)

@wgordon17
Copy link
Contributor Author

@blueyed Any thoughts on when you'd want to merge this?

@wgordon17 wgordon17 force-pushed the add_django_asserts branch 2 times, most recently from 544cf4d to dcee2d6 Compare January 11, 2020 01:25
A bug was discovered in the way that asserts as contextmanagers was being handled.
The contextmanager asserts needed to return an actual class, and not just act solely as an assert.
This commit fixes that bug
@pytest-dev pytest-dev deleted a comment from codecov-io Jan 11, 2020
@pytest-dev pytest-dev deleted a comment from codecov-io Jan 11, 2020
@pytest-dev pytest-dev deleted a comment from codecov-io Jan 11, 2020
@blueyed
Copy link
Contributor

blueyed commented Jan 11, 2020

Thanks for the update, I've pushed two improvements (better docs (star imports are discouraged), and changed it to use functools.wraps (for doc etc)).

@Mogost
Copy link
Contributor

Mogost commented Jan 13, 2020

It looks so simple but so necessary. I look forward to the merge of this PR.

@wgordon17
Copy link
Contributor Author

@blueyed Thanks so much for those improvements! 🙏

@blueyed blueyed merged commit febbff4 into pytest-dev:master Jan 13, 2020
@blueyed
Copy link
Contributor

blueyed commented Jan 13, 2020

Thanks! :)

@blueyed
Copy link
Contributor

blueyed commented Jan 14, 2020

Released in 3.8.0.. 🎉

The-Compiler added a commit to studentenportal/web that referenced this pull request Jan 17, 2020
- api.test_serializers
- api.test_views
- documents.test_models
- events.test_models
- front.test_templatetags
- front.test_views (partially)
- lecturers.test_ajax
- lectures.test_models

Some files couldn't be rewritten because of missing assertion methods:
pytest-dev/pytest-django#709

Given that this PR was recently merged, after upgrading dependencies we could
take another shot at this.
@premchalmeti
Copy link

@wgordon17 Any reason for not including unittest.TestCase asserts?

@wgordon17
Copy link
Contributor Author

@premchalmeti, since this repo focuses on Django, it made more sense to focus only on the Django asserts. Additionally, most (if not all) the unittest.TestCase asserts are something that should be more appropriately handled by traditional assert statements, as is the pytest philosophy.

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

Successfully merging this pull request may close these issues.

None yet

6 participants