Python Unittest: AttributeError: no attribute 'assertTrue' when running on Linux

Viewed 2118

I am running some very simple unit tests in Python, and found that the assertTrue() function won't work, while in the same testcase the assertEqual() is working fine. To simplify the issue, I have minimized the code into the following:

import unittest

class easyTest (unittest.TestCase):
    def setUp(self):
        pass

    def test_true(self):
        self.assertTrue(True)

if __name__ == "__main__":
    unittest.main()

This batch of codes runs perfectly on my Windows laptop, but returns

AttributeError: easyTest instance has no attribute 'assertTrue'

when I try to run it on Linux.

On both laptops, I am using python 2.7.6, on IDE pyCharm Community Edition 2017.1.4. My Linux laptop is running Ubuntu 14.04.1

I have found a very similar question here: AttributeError: TestSwitch instance has no attribute 'assertTrue' And since it seems that nobody is answering the question, I am asking here again, hoping for some prominent answers.

2 Answers
Related