1import unittest
2
3from secret import validate_recipe, RuinedNikuldenDinnerError
4
5class TestNikuldenValidator:
6 def test_valid_recipe(self):
7 file = open('test_valid_recipe.txt', 'w')
8 file.write('Добре посолена морска риба')
9 self.assertTrue(validate_recipe('test_valid_recipe.txt'))
10
11 def test_invalid_recipe(self):
12 file = open('test_invalid_recipe.txt', 'w')
13 file.write('Свинско месо, вино, сол, пипер')
14 self.assertFalse(validate_recipe('test_invalid_recipe.txt'))
15
16 def test_bad_recipe_file(self):
17 try:
18 validate_recipe('ivalid_file.txt')
19 except Exception as e:
20 self.assertIsInstance(e, RuinedNikuldenDinnerError)
21
22
23if __name__ == '__name__':
24 unittest.main()
EEEE
======================================================================
ERROR: test_naive_in_validator (test.TestTestNikuldenValidator.test_naive_in_validator)
Test with implementation missing word splits.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 90, in test_naive_in_validator
result = self.TestNikuldenValidator(test_name)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TestNikuldenValidator() takes no arguments
======================================================================
ERROR: test_no_error_handling_validator (test.TestTestNikuldenValidator.test_no_error_handling_validator)
Test with implementation missing error handling.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 75, in test_no_error_handling_validator
result = self.TestNikuldenValidator(test_name)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TestNikuldenValidator() takes no arguments
======================================================================
ERROR: test_no_lower_validator (test.TestTestNikuldenValidator.test_no_lower_validator)
Test with implementation missing lower.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 60, in test_no_lower_validator
result = self.TestNikuldenValidator(test_name)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TestNikuldenValidator() takes no arguments
======================================================================
ERROR: test_valid_validator (test.TestTestNikuldenValidator.test_valid_validator)
Test with a valid implementation.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 49, in test_valid_validator
result = self.TestNikuldenValidator(test_name)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TestNikuldenValidator() takes no arguments
----------------------------------------------------------------------
Ran 4 tests in 0.002s
FAILED (errors=4)
07.12.2024 13:14
07.12.2024 13:14