1920 elif status == 204:
1921 body = {"values": [], "isLastPage": True}
1922 else:
1923 body = self._bb_api_error_stub1924
1925 if pages > 0: # Add paginated irrelevant responses
1926 while pages > 0:
1247 status=403,
1248 )
1249 else:
1250 responses.add(1251 responses.POST,
1252 "https://gitlab.com/api/v4/projects/WeblateOrg%2Ftest/fork",
1253 json={
124 def setUp(self) -> None:
125 super().setUp()
126 if not self._class.is_supported():
127 raise SkipTest("Not supported") 128
129 self.clone_test_repos()
130
151 # Remove stale dir from previous tests
152 target = os.path.join(data_dir("vcs"), "xxxx")
153 if os.path.exists(target):
154 remove_tree(target)155 self.make_manager()
156 self.assertContains(
157 self.client.get(self.project.get_absolute_url()), "#organize"
207 )
208 self.assertEqual(unit.target, "Ahoj svete!\n")
209 else:
210 self.assertContains(211 response, "Search and replace completed, no strings were updated."212 )213 self.assertEqual(unit.target, "Nazdar svete!\n")214
215 def test_no_match(self) -> None:
216 response = self.client.post(
Test code has lines of code that were never executed during the test. This can happen when you've written test for some application logic which is never hit during the tests.
If you're doing TDD (Test Driven Development), this could be a result of a use-case that you forgot to handle. Another reason could be the presence of dead code in your tests, which you should refactor and take action on.
It is strongly recommended to review the occurrences and make sure your're not missing anything.
Let's assume thet we are making a pattern generator that only generates hexagons and circle. Below is a test for the generator:
def test_pattern_generator():
'''Make sure that the pattern generator is accurate.'''
data = "This is intentionally kept constant for this example."
match pattern.name:
case circle:
assert pattern_is_circle(pattern.ascii)
# This would never be hit, because you forgot to implement it.
case hexagon:
assert pattern_is_hexagon(pattern.ascii)
case triangle:
assert pattern_is_triangle(pattern.ascii)
if not data: # Dead code block, since data is a constant and always Truthy.
pattern.generate() # This line would never be executed.