3

I don't understand something, with the python unittest discover. I made this project:

project/
    __init__.py
    src/
        __init__.py
        criteria.py
    tests/
        __init__.py
        criteria_test.py

And to be able to know if I loaded the test correctly I ensure myself to make it fail with the code below

# coding: utf-8
import unittest

class TestCriteria(unittest.TestCase):
    def setUp(self):
        pass
    def test_criteriaFailure(self):
        self.assertTrue(False)

When I do the command in the command-line, I'm at the file project (the root of my packages), I guess everything can be imported.

I tried:

python -m unittest discover
python -m unittest discover -s tests -p '*_test.py'

but it always return me this output:

Ran 0 tests in 0.000s

Ok

I'd like to understand how to use this feature (I'm using python3.2.3) without having to download and install Nose.

1
  • Is there a solution to this question? Commented Oct 17, 2019 at 11:23

1 Answer 1

1

Is there anything in your tests/__init__.py file?

I'm looking into the source of unittest (Python's all open source, and very readable -- you can do it too :) ), because I'm more familiar with the Django test runner, but it is likely that your __init__.py file should at least have a line that looks like this:

from criteria_test import *
Sign up to request clarification or add additional context in comments.

2 Comments

Well, it did not help, but you gave me the idea of going explore how people did on their projects in github. I have found a solution, with the TestLoader... Thanks anyways :)
Is there a solution to this question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.