assert<Bool>
PYL-W150311 dataset = FederatedDataset(np.random.rand(100, 3, 224, 224), np.random.randint(0, 10, 100))
12 model = load_model()
13 train_model(model, dataset)
14 self.assertTrue(True)15
16 def test_federated_learning_inference(self):
17 model = load_model()
25 model = load_model()
26 input_data = torch.randn(1, 3, 224, 224)
27 explainable_ai_inference(model, input_data)
28 self.assertTrue(True)29
30if __name__ == "__main__":
31 unittest.main()
19 feature_names = ["input_data_0", "input_data_1", "input_data_2", ...]
20 explain_model(model, input_data)
21 visualize_shap_values(shap_values, feature_names)
22 self.assertTrue(True)23
24 def test_explainable_ai_inference(self):
25 model = load_model()
18 teacher = EdgeAIModel()
19 student = EdgeAIModel()
20 model_knowledge_distillation(student, teacher, dataset)
21 self.assertTrue(True)22
23if __name__ == "__main__":
24 unittest.main()
11 def test_model_pruning(self):
12 model = load_model()
13 model_pruning(model)
14 self.assertTrue(True)15
16 def test_model_knowledge_distillation(self):
17 dataset = EdgeAIDataset(np.random.rand(100, 3, 224, 224), np.random.randint(0, 10, 100))
The first argument of assertTrue
and assertFalse
should be a condition.
If a constant is passed as a parameter, the condition will be always True
, making the test meaningless.
import unittest
class Tests(unittest.TestCase):
def test_something(self):
''' Some test '''
self.assertTrue('My String')
import unittest
class Tests(unittest.TestCase):
def test_something(self):
''' Simple test '''
string = 'My String'
self.assertTrue('My String' == string)
You also might accidentally use assertTrue
instead of assertEqual
, which also causes this issue to be raised.
import unittest
class Tests(unittest.TestCase):
def test_something(self):
''' Simple test '''
some_var = 'It should be assertEqual'
self.assertTrue('I meant assertEqual not assertTrue', some_var)
import unittest
class Tests(unittest.TestCase):
def test_something(self):
''' Simple test '''
some_var = 'It should be assertEqual'
self.assertEqual('I meant assertEqual not assertTrue', some_var)