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

Install pytest #533

Merged
merged 5 commits into from Apr 11, 2021
Merged

Install pytest #533

merged 5 commits into from Apr 11, 2021

Conversation

noobOriented
Copy link
Contributor

修改

裝 pytest-django 並且把 unittest 的 TestCase pattern 通通幹掉

有一些順手加了一些 fixture

並加入兩個 test helper wrapper: Unordered 和 SuperSet

[1, 2, 2, 3] == Unordered([3, 2, 2, 1])  # True
{'a': 1, 'b': 2} == SuperSet({'a': 1})  # True

備註

pytest-django: https://pytest-django.readthedocs.io/en/latest/index.html

  • 如果測試要用到 db,需要:
@pytest.mark.django_db
def test_...

@pytest.mark.django_db
class Test...
    def test_...

pytestmark = pytest.mark.django_db  # 或 [pytest.mark.django_db, ...]
  • fixture 要用到 db,需要:
@pytest.fixture
def blabla(db):
    ...

TODO

更多東西需要 fixture 和 parametrize
style 部分下一 PR 修

Copy link
Contributor

@LittleWhiteYA LittleWhiteYA left a comment

Choose a reason for hiding this comment

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

應該 ... 還行..?

@noobOriented noobOriented merged commit 2ee1ca1 into master Apr 11, 2021
@noobOriented noobOriented deleted the install-pytest branch April 11, 2021 06:00
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

Successfully merging this pull request may close these issues.

None yet

2 participants