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

Remove setUpTestData from PlaywrightTestCase #67

Merged
merged 1 commit into from
Sep 21, 2022
Merged

Conversation

jedie
Copy link
Collaborator

@jedie jedie commented Sep 21, 2022

Remove setUpTestData from PlaywrightTestCase because it doesn't work call this from
setUpClass, because all data will be removed after the first test.

The PlaywrightTestCase used StaticLiveServerTestCase that inherits from TransactionTestCase
that will flush the database after each tests.

The LiveServerTestCase doc string says:

It inherits from TransactionTestCase instead of TestCase because the
threads don't share the same transactions (unless if using in-memory sqlite)
and each thread needs to commit all their transactions so that the other
thread can see the changes.

See also: https://code.djangoproject.com/ticket/23640

We can call setUpTestData from setUp. But the class method setUpTestData originally stands for
initializing test data for the entire test case, so don't do this. It's up to the child class how to
create initial test data.

Raise a warning if there is a setUpTestData to clarify that it's not usable.

Additional fixes:

Remove pytest warning by add the marker to [tool.pytest.ini_options]:

PytestUnknownMarkWarning: Unknown pytest.mark.playwright - is this a typo?  You can register custom
marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.playwright

Split github actions PyPi cache, see: python-poetry/poetry#4568

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2022

Codecov Report

Merging #67 (ed4ebc6) into master (6edc656) will decrease coverage by 0.03%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
- Coverage   94.90%   94.87%   -0.04%     
==========================================
  Files         100      100              
  Lines        3611     3608       -3     
==========================================
- Hits         3427     3423       -4     
- Misses        184      185       +1     
Impacted Files Coverage Δ
bx_django_utils/test_utils/playwright.py 58.53% <0.00%> (-2.18%) ⬇️
bx_django_utils/__init__.py 100.00% <100.00%> (ø)
...django_utils_tests/tests/test_playwright_helper.py 67.85% <100.00%> (-1.11%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Remove `setUpTestData` from `PlaywrightTestCase` because it doesn't work call this from
`setUpClass`, because all data will be removed after the first test.

The `PlaywrightTestCase` used `StaticLiveServerTestCase` that inherits from `TransactionTestCase`
that will flush the database after each tests.

The `LiveServerTestCase` doc string says:
```
It inherits from TransactionTestCase instead of TestCase because the
threads don't share the same transactions (unless if using in-memory sqlite)
and each thread needs to commit all their transactions so that the other
thread can see the changes.
```
See also: https://code.djangoproject.com/ticket/23640

We can call `setUpTestData` from `setUp`. But the class method `setUpTestData` originally stands for
initializing test data for the entire test case, so don't do this. It's up to the child class how to
create initial test data.

Raise a warning if there is a `setUpTestData` to clarify that it's not usable.

Additional fixes:

Remove pytest warning by add the marker to `[tool.pytest.ini_options]`:
```
PytestUnknownMarkWarning: Unknown pytest.mark.playwright - is this a typo?  You can register custom
marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.playwright
```

Split github actions PyPi cache, see: python-poetry/poetry#4568
@phihag phihag merged commit 86e98b6 into master Sep 21, 2022
@phihag phihag deleted the fix-playwright branch September 21, 2022 09:41
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

3 participants