question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tests failures because of missing_module_test

See original GitHub issue

General Information:

  • OS: Ubuntu 20.04
  • Python version: 3.10.4
  • Library version: 0.8.4

Describe the bug: When I execute python3 -m unittest dataprofiler/tests/reports/test_graphs.py

test_no_matplotlib seems to break something internal within matplotlib.

After it runs, multiple other tests in test_graphs.py fail with the error:

======================================================================
ERROR: test_null_list (dataprofiler.tests.reports.test_graphs.TestPlotMissingValuesMatrix)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/codespace/.python/current/lib/python3.10/unittest/mock.py", line 1369, in patched
    return func(*newargs, **newkeywargs)
  File "/workspaces/DataProfiler/dataprofiler/tests/reports/test_graphs.py", line 222, in test_null_list
    fig = graphs.plot_missing_values_matrix(profiler)
  File "/workspaces/DataProfiler/dataprofiler/reports/utils.py", line 50, in new_f
    return f(*args, **kwds)
  File "/workspaces/DataProfiler/dataprofiler/reports/graphs.py", line 208, in plot_missing_values_matrix
    return plot_col_missing_values(profiler.profile, ax=ax, title=title)
  File "/workspaces/DataProfiler/dataprofiler/reports/utils.py", line 50, in new_f
    return f(*args, **kwds)
  File "/workspaces/DataProfiler/dataprofiler/reports/graphs.py", line 259, in plot_col_missing_values
    fig = plt.figure()
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 454, in wrapper
    return func(*args, **kwargs)
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/pyplot.py", line 771, in figure
    manager = new_figure_manager(
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/pyplot.py", line 346, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/pyplot.py", line 336, in _warn_if_gui_out_of_main_thread
    if (_get_required_interactive_framework(_get_backend_mod()) and
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/pyplot.py", line 206, in _get_backend_mod
    switch_backend(dict.__getitem__(rcParams, "backend"))
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/pyplot.py", line 251, in switch_backend
    switch_backend(candidate)
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/pyplot.py", line 288, in switch_backend
    class backend_mod(matplotlib.backend_bases._Backend):
  File "/workspaces/DataProfiler/venv/lib/python3.10/site-packages/matplotlib/_api/__init__.py", line 224, in __getattr__
    raise AttributeError(
AttributeError: module 'matplotlib' has no attribute 'backend_bases'

When the tests are run individually they work fine:

/workspaces/DataProfiler ❯❯❯ python3 -m unittest dataprofiler.tests.reports.test_graphs.TestPlotMissingValuesMatrix.test_null_list

.
----------------------------------------------------------------------
Ran 1 test in 0.069s

OK

If I comment out test_no_matplotlib then all of the tests pass when running python3 -m unittest dataprofiler/tests/reports/test_graphs.py

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JGSweetscommented, Dec 3, 2022

#736 is a rework that should prevent this error in the future as now we don’t modify the modules themselves.

0reactions
JGSweetscommented, Dec 3, 2022

In regards to testing, I think we should mimic the CI as well. We should also update the ghpages to show the same where different. However, we shouldn’t restrict as both should function in the current design.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Diagnosing Random Angular Test Failures - WalkingRiver.com
The trick now was to figure out which one. On a whim, I decided to turn off random ordering in the Jasmine configuration....
Read more >
"Randomly" failing tests | Apple Developer Forums
We have a test suite that passes when tests are run manually via Xcode. ... Has anyone else had problems with sporadic Xcode...
Read more >
How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
Unit tests sometimes failing, sometimes passing - Stack Overflow
Tests can fail intermittently for a number of reasons and identifying why they fail is often revealing about your codebase and environment.
Read more >
Failing at Integration Testing: Common Mistakes - TestQuality
Integration tests are slow and difficult to maintain because they have substantially more system touch points than unit tests and hence ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found