简体   繁体   中英

How to get tests to run with unittest?

Wanted to use unittest for some data examples.

import unittest

from peculiar.py import misma_paridad, alterna_paridad


class TestMismaParidad(unittest.TestCase):
    def test_misma_paridad(self):
        self.assertTrue(misma_paridad(0, 0))
        self.assertFalse(misma_paridad(0, 1))

class TestAlternaParidad(unittest.TestCase):
    def test_alterna_paridad(self):
        self.assertTrue(alterna_paridad(1234))
        self.assertFalse(alterna_paridad(1224))


unittest.main()

After several attempts of editing code, still getting:

Ran 0 tests in 0.000s

OK

Can someone tell me where the issue might be?

Adding a blank __init__.py file to the same folder my test was in fixed it for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM