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.

`unittest` TestCase collection fails silently when there are unclear circular dependencies

See original GitHub issue

Hey! I have problem with collecting unittest/asynctest based test.

I’m trying to run tests TestCase from unittest/asynctest and have problem when I provide for example exact dir pytest directory_name then collecting works fine, it will collect correct test and run it but when I will run pytest without directory pytest it’s collecting same tests but in this case it skipps all of them becasue it has init method defined from testcase.

PytestCollectionWarning: cannot collect test class 'TestCase' because it has a __init__ constructor 

but If I run it directly, by passing pytest test_name.py or pytest dir_name it will run single test or in second case, it will collect correctly test from dir and run it

In every case the same test are collected but in one is skipped and in another it run normally.

also https://docs.pytest.org/en/stable/unittest.html it says that pytest tests should run unittest style test but it will work only if there are in test dir, right?

Is it bug or missing configuration?

  • pytest 6.2.2
  • asynctest 0.13.0
  • python 3.9.1
  • osx Big Sur on m1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RonnyPfannschmidtcommented, Feb 18, 2021

Yes please, if a circular dependency in code somehow breaks collection, there should be a error at least

I wonder why pytest lacks it

0reactions
Zac-HDcommented, Sep 27, 2022

Closing because we don’t have the needed information to resolve this, happy to reopen if that changes 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit-testing with dependencies between tests - python
pass or fail are meaningless for tests with unmet dependencies. If creating an object fails or the object is created but results with...
Read more >
Cyclic namespace dependencies! - Google Groups
My latest case is that I'm trying to debug a weird Java interop problem--something that works in one app I've written, in which...
Read more >
harfbuzz and freetype circular dependency -- unable to fix
I've had an awesome experience with Gentoo thus far, and got my initial installation + KDE environment set up relatively without pain; however,...
Read more >
systemctl - Freedesktop.org
fail, because the manager will still forcibly terminate the unit. reload PATTERN …¶. Asks all units listed on the command line to reload...
Read more >
The mesh file exporter could not resolve cyclic dependencies ...
I do have a multi-body geometry. They are essentially PCBs stacked on top of one another. But how can I avoid this error...
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