Skip to content

Commit 609ab56

Browse files
authored
Update test_uuid.py
1 parent 2c9a801 commit 609ab56

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Lib/test/test_uuid.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,64 @@ def test_cli_uuid5_ouputted_with_valid_namespace_and_name(self):
12141214
self.assertEqual(output, str(uuid_output))
12151215
self.assertEqual(uuid_output.version, 5)
12161216

1217+
@mock.patch.object(sys, "argv",
1218+
["", "-u", "uuid1"])
1219+
def test_cli_uuid1(self):
1220+
stdout = io.StringIO()
1221+
with contextlib.redirect_stdout(stdout):
1222+
self.uuid.main()
1223+
1224+
output = stdout.getvalue().strip()
1225+
uuid_output = self.uuid.UUID(output)
1226+
1227+
# Output should be in the form of uuid1
1228+
self.assertEqual(output, str(uuid_output))
1229+
self.assertEqual(uuid_output.version, 1)
1230+
1231+
1232+
@mock.patch.object(sys, "argv",
1233+
["", "-u", "uuid6"])
1234+
def test_cli_uuid6(self):
1235+
stdout = io.StringIO()
1236+
with contextlib.redirect_stdout(stdout):
1237+
self.uuid.main()
1238+
1239+
output = stdout.getvalue().strip()
1240+
uuid_output = self.uuid.UUID(output)
1241+
1242+
# Output should be in the form of uuid6
1243+
self.assertEqual(output, str(uuid_output))
1244+
self.assertEqual(uuid_output.version, 6)
1245+
1246+
1247+
@mock.patch.object(sys, "argv",
1248+
["", "-u", "uuid7"])
1249+
def test_cli_uuid7(self):
1250+
stdout = io.StringIO()
1251+
with contextlib.redirect_stdout(stdout):
1252+
self.uuid.main()
1253+
1254+
output = stdout.getvalue().strip()
1255+
uuid_output = self.uuid.UUID(output)
1256+
1257+
# Output should be in the form of uuid7
1258+
self.assertEqual(output, str(uuid_output))
1259+
self.assertEqual(uuid_output.version, 7)
1260+
1261+
1262+
@mock.patch.object(sys, "argv",
1263+
["", "-u", "uuid8"])
1264+
def test_cli_uuid8(self):
1265+
stdout = io.StringIO()
1266+
with contextlib.redirect_stdout(stdout):
1267+
self.uuid.main()
1268+
1269+
output = stdout.getvalue().strip()
1270+
uuid_output = self.uuid.UUID(output)
1271+
1272+
# Output should be in the form of uuid8
1273+
self.assertEqual(output, str(uuid_output))
1274+
self.assertEqual(uuid_output.version, 8)
12171275

12181276
class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase):
12191277
uuid = py_uuid

0 commit comments

Comments
 (0)