Alexey Orlov
Alexey Orlov

Reputation: 2814

Eric IDE: running unit tests inside IDE

I've got a small project and running unit tests:

$ python tests/runner.py 
......
----------------------------------------------------------------------
Ran 6 tests in 0.002s
OK
$ python -m tests.runner
......
----------------------------------------------------------------------
Ran 6 tests in 0.002s
OK

tests/runner.py:

import unittest

loader = unittest.TestLoader()
tests = loader.discover('.')
testRunner = unittest.runner.TextTestRunner()
testRunner.run(tests)

tests/test_common.py (a single test case, nothing else):

from procr.core.pcp import *  # pcp - module under test.

class TestHelpers(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_something(self):
    ...

Directory structure:

project/
  __init__.py
  procr/
    core/
      __init__.py
      pcp.py
    __init__.py
  tests/
    __init__.py
    test_common.py
    runner.py

Eric IDE requires a test, or test suite file. Supplied with runner.py it reports Error: suite(unittest.loader._FailedTest). Project directory is set to project, full path.

What can be possibly wrong?

UPD:

The tests even actually run, as shown in the Eric console. The IDE probably expects something a bit different from the runner. I've no idea what.

Upvotes: 0

Views: 253

Answers (1)

Alexey Orlov
Alexey Orlov

Reputation: 2814

This is no Eric Unittest Manual, not by any means. Yet it is better than nothing. At least a small step forward.

A soft link to tests/test_common.py (otherwise the working directory shifts from the project):

project/
  __init__.py
  procr/
    core/
      __init__.py
      pcp.py
    __init__.py
  tests/
    __init__.py
    test_common.py
    runner.py

  eric_test_common.py -> tests/test_common.py

Eric Unittest Dialog:

  • Enter test filename: full path to eric_test_common.py

  • Enter test name: TestHelpers

  • Run local: check

  • Start: push

It's just the first working option I discovered; there must be much more. I hope to make this answer better in time.

Eric Unittest Dialog on GitHub

Upvotes: 0

Related Questions