-
-
Notifications
You must be signed in to change notification settings - Fork 123
Rewrite tests with dash testing #153
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
Conversation
setting position causes tests to fail sometimes
I'll look into it, thanks. |
It should be fixed now. However, it needs manual approval. Since |
tests/test_callbacks.py
Outdated
|
||
self.dash_duo.driver.save_screenshot(path) | ||
|
||
def test_callbacks(self, dash_duo): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our usual usage of dash.testing
does not create classes at all - just functions, and they should include test case ids, for which our convention is 4 characters to identify the file and three numbers for the test case within the file. So this one might be test_cycb001_callbacks(dash_duo)
, in test_interactions.py
they might be test_cyin001_dragging
, test_cyin002_clicking
etc... the advantage here is you can easily run exactly the test you want using for example pytest -k cyin002
.
Helper functions like create_input_and_save
can either be nested inside the test case (if they're only used in one place like in this file) or they can be explicitly passed dash_duo
tests/test_percy_snapshot.py
Outdated
@@ -74,36 +68,20 @@ def display_image(pathname): # pylint: disable=W0612 | |||
|
|||
return app | |||
|
|||
def percy_snapshot(self, name=''): | |||
@staticmethod | |||
def percy_snapshot(dash_duo, name=''): | |||
if os.environ.get('PERCY_ENABLED', False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to explicitly check PERCY_ENABLED
- dash_duo.percy_snapshot
is a noop if percy is disabled.
tests/test_percy_snapshot.py
Outdated
) | ||
time.sleep(2) | ||
|
||
def test_usage(self): | ||
# Create and start the app | ||
def test_usage(self, dash_duo): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole set of tests would be a great use case for pytest.mark.parametrize
, eg:
import pytest
@pytest.mark.parametrize('name', ['usage', 'elements', 'layouts', 'style'])
def test_cyps001_snapshots(name, dash_duo):
app = self.create_app(dir_name=name)
dash_duo.start_server(app)
run_percy_on(name, dash_duo)
tests/test_usage.py
Outdated
def test_usage_advanced(self): | ||
self.create_usage_test('usage-advanced') | ||
def test_usage_advanced(self, dash_duo): | ||
self.create_usage_test(dash_duo, 'usage-advanced') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest.mark.parametrize
again :)
Thanks @alexcjohnson I mainly rewrote the existing code by using |
About
Fixes #118, rewrite the tests with
dash[testing]
Description of changes
Pre-Merge checklist
npm run build:all
.Reference Issues
Closes #[issue number]
Other comments