Skip to content

Commit b84e504

Browse files
committed
Reorder uuid cli tests and fix comment typo
1 parent 0f01998 commit b84e504

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

Lib/test/test_uuid.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,44 +1182,17 @@ def test_cli_name_required_for_uuid3(self, mock_err):
11821182
self.assertEqual(cm.exception.code, 2)
11831183
self.assertIn("error: Incorrect number of arguments", mock_err.getvalue())
11841184

1185-
@mock.patch.object(sys, "argv", [""])
1186-
def test_cli_uuid4_outputted_with_no_args(self):
1187-
stdout = io.StringIO()
1188-
with contextlib.redirect_stdout(stdout):
1189-
self.uuid.main()
1190-
1191-
output = stdout.getvalue().strip()
1192-
uuid_output = self.uuid.UUID(output)
1193-
1194-
# Output uuid should be in the format of uuid4
1195-
self.assertEqual(output, str(uuid_output))
1196-
self.assertEqual(uuid_output.version, 4)
1197-
1198-
@mock.patch.object(sys, "argv", ["", "-C", "3"])
1199-
def test_cli_uuid4_outputted_with_count(self):
1200-
stdout = io.StringIO()
1201-
with contextlib.redirect_stdout(stdout):
1202-
self.uuid.main()
1203-
1204-
output = stdout.getvalue().strip().splitlines()
1205-
1206-
# Check that 3 UUIDs in the format of uuid4 have been generated
1207-
self.assertEqual(len(output), 3)
1208-
for o in output:
1209-
uuid_output = self.uuid.UUID(o)
1210-
self.assertEqual(uuid_output.version, 4)
1211-
12121185
@mock.patch.object(sys, "argv",
12131186
["", "-u", "uuid3", "-n", "@dns", "-N", "python.org"])
1214-
def test_cli_uuid3_ouputted_with_valid_namespace_and_name(self):
1187+
def test_cli_uuid3_outputted_with_valid_namespace_and_name(self):
12151188
stdout = io.StringIO()
12161189
with contextlib.redirect_stdout(stdout):
12171190
self.uuid.main()
12181191

12191192
output = stdout.getvalue().strip()
12201193
uuid_output = self.uuid.UUID(output)
12211194

1222-
# Output should be in the form of uuid5
1195+
# Output should be in the form of uuid3
12231196
self.assertEqual(output, str(uuid_output))
12241197
self.assertEqual(uuid_output.version, 3)
12251198

@@ -1238,7 +1211,7 @@ def test_cli_uuid3_with_invalid_namespace(self, mock_err):
12381211
["", "-u", "uuid3", "-n",
12391212
"0d6a16cc-34a7-47d8-b660-214d0ae184d2",
12401213
"-N", "some.user"])
1241-
def test_cli_uuid3_ouputted_with_custom_namespace_and_name(self):
1214+
def test_cli_uuid3_outputted_with_custom_namespace_and_name(self):
12421215
stdout = io.StringIO()
12431216
with contextlib.redirect_stdout(stdout):
12441217
self.uuid.main()
@@ -1250,9 +1223,36 @@ def test_cli_uuid3_ouputted_with_custom_namespace_and_name(self):
12501223
self.assertEqual(output, str(uuid_output))
12511224
self.assertEqual(uuid_output.version, 3)
12521225

1226+
@mock.patch.object(sys, "argv", [""])
1227+
def test_cli_uuid4_outputted_with_no_args(self):
1228+
stdout = io.StringIO()
1229+
with contextlib.redirect_stdout(stdout):
1230+
self.uuid.main()
1231+
1232+
output = stdout.getvalue().strip()
1233+
uuid_output = self.uuid.UUID(output)
1234+
1235+
# Output uuid should be in the format of uuid4
1236+
self.assertEqual(output, str(uuid_output))
1237+
self.assertEqual(uuid_output.version, 4)
1238+
1239+
@mock.patch.object(sys, "argv", ["", "-C", "3"])
1240+
def test_cli_uuid4_outputted_with_count(self):
1241+
stdout = io.StringIO()
1242+
with contextlib.redirect_stdout(stdout):
1243+
self.uuid.main()
1244+
1245+
output = stdout.getvalue().strip().splitlines()
1246+
1247+
# Check that 3 UUIDs in the format of uuid4 have been generated
1248+
self.assertEqual(len(output), 3)
1249+
for o in output:
1250+
uuid_output = self.uuid.UUID(o)
1251+
self.assertEqual(uuid_output.version, 4)
1252+
12531253
@mock.patch.object(sys, "argv",
12541254
["", "-u", "uuid5", "-n", "@dns", "-N", "python.org"])
1255-
def test_cli_uuid5_ouputted_with_valid_namespace_and_name(self):
1255+
def test_cli_uuid5_outputted_with_valid_namespace_and_name(self):
12561256
stdout = io.StringIO()
12571257
with contextlib.redirect_stdout(stdout):
12581258
self.uuid.main()

0 commit comments

Comments
 (0)