craigahobbs / unittest-parallel

Parallel unit test runner for Python with coverage support
MIT License
29 stars 5 forks source link

Windows support #7

Closed SweetVishnya closed 3 years ago

SweetVishnya commented 3 years ago

Hi!

Do you support Windows?

SweetVishnya commented 3 years ago
Traceback (most recent call last):
  File "C:\Users\vishnya\AppData\Roaming\Python\Python36\Scripts\unittest-parallel-script.py", 
line 11, in <module>
    load_entry_point('unittest-parallel==1.1.0', 'console_scripts', 'unittest-parallel')()
  File "C:\Users\vishnya\AppData\Roaming\Python\Python36\site-packages\unittest_parallel\main.p
y", line 75, in main
    test_suites = test_loader.discover(args.start_directory, pattern=args.pattern, top_level_di
r=args.top_level_directory)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\unittest\loader.p
y", line 338, in discover
    raise ImportError('Start directory is not importable: %r' % start_dir)
craigahobbs commented 3 years ago

Yes, Windows is fully supported. Unit tests all pass on Windows with 100% branch coverage. I also verified that unittest-parallel works with a real-world project on Windows.

What does your source tree look like?

SweetVishnya commented 3 years ago

Creating __init__.py in tests helped. But now it runs my unittest functions sequential.

craigahobbs commented 3 years ago

How many TestCase classes do you have?

unitest-parallel runs unit tests for all TestClass classes in parallel. If you have only one TestCase class, there will be no parallelization.

The reason for this is that TestCase's setUp method implies that per-test-case state may be applied to the test case instance - and thus, tests within a TestClass instance can, in general, only safely be run one at a time.

SweetVishnya commented 3 years ago

I have two TestCase classes, one function each.

craigahobbs commented 3 years ago

Hmmm... How many test files?

SweetVishnya commented 3 years ago

One test file.

craigahobbs commented 3 years ago

I will take a look at that case.

What happens if you break your tests into multiple files?

SweetVishnya commented 3 years ago

They run in parallel. So, this does not work with one file.

craigahobbs commented 3 years ago

How are you defining your unit tests within the single file? An example would be helpful.

craigahobbs commented 3 years ago

This is an issue even when defining multiple TestCase classes in a single file - they are run as a single aggregate test suite. It would be far better to run each separately. I'm looking into a fix.

SweetVishnya commented 3 years ago

This is an issue even when defining multiple TestCase classes in a single file - they are run as a single aggregate test suite. It would be far better to run each separately. I'm looking into a fix.

This is exactly my case.

craigahobbs commented 3 years ago

Now parallelize based on TestCase's, not just top-level test suites.

Released unittest-parallel 1.2.0