| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac807cb commit 33f561d
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1140,6 +1140,23 @@ def test_uuid_weakref(self): | |||
| 1140 | 1140 | weak = weakref.ref(strong) | |
| 1141 | 1141 | self.assertIs(strong, weak()) | |
| 1142 | 1142 | ||
| 1143 | + | ||
| 1144 | + class CommandLineTestCases: | ||
| 1145 | + uuid = None # to be defined in subclasses | ||
| 1146 | + | ||
| 1147 | + def do_test_standalone_uuid(self, version): | ||
| 1148 | + stdout = io.StringIO() | ||
| 1149 | + with contextlib.redirect_stdout(stdout): | ||
| 1150 | + self.uuid.main() | ||
| 1151 | + output = stdout.getvalue().strip() | ||
| 1152 | + u = self.uuid.UUID(output) | ||
| 1153 | + self.assertEqual(output, str(u)) | ||
| 1154 | + self.assertEqual(u.version, version) | ||
| 1155 | + | ||
| 1156 | + @mock.patch.object(sys, "argv", ["", "-u", "uuid1"]) | ||
| 1157 | + def test_cli_uuid1(self): | ||
| 1158 | + self.do_test_standalone_uuid(1) | ||
| 1159 | + | ||
| 1143 | 1160 | @mock.patch.object(sys, "argv", ["", "-u", "uuid3", "-n", "@dns"]) | |
| 1144 | 1161 | @mock.patch('sys.stderr', new_callable=io.StringIO) | |
| 1145 | 1162 | def test_cli_namespace_required_for_uuid3(self, mock_err): | |
@@ -1214,13 +1231,25 @@ def test_cli_uuid5_ouputted_with_valid_namespace_and_name(self): | |||
| 1214 | 1231 | self.assertEqual(output, str(uuid_output)) | |
| 1215 | 1232 | self.assertEqual(uuid_output.version, 5) | |
| 1216 | 1233 | ||
| 1234 | + @mock.patch.object(sys, "argv", ["", "-u", "uuid6"]) | ||
| 1235 | + def test_cli_uuid6(self): | ||
| 1236 | + self.do_test_standalone_uuid(6) | ||
| 1237 | + | ||
| 1238 | + @mock.patch.object(sys, "argv", ["", "-u", "uuid7"]) | ||
| 1239 | + def test_cli_uuid7(self): | ||
| 1240 | + self.do_test_standalone_uuid(7) | ||
| 1241 | + | ||
| 1242 | + @mock.patch.object(sys, "argv", ["", "-u", "uuid8"]) | ||
| 1243 | + def test_cli_uuid8(self): | ||
| 1244 | + self.do_test_standalone_uuid(8) | ||
| 1245 | + | ||
| 1217 | 1246 | ||
| 1218 | - class TestUUIDWithoutExtModule(BaseTestUUID, unittest.TestCase): | ||
| 1247 | + class TestUUIDWithoutExtModule(CommandLineTestCases, BaseTestUUID, unittest.TestCase): | ||
| 1219 | 1248 | uuid = py_uuid | |
| 1220 | 1249 | ||
| 1221 | 1250 | ||
| 1222 | 1251 | @unittest.skipUnless(c_uuid, 'requires the C _uuid module') | |
| 1223 | - class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase): | ||
| 1252 | + class TestUUIDWithExtModule(CommandLineTestCases, BaseTestUUID, unittest.TestCase): | ||
| 1224 | 1253 | uuid = c_uuid | |
| 1225 | 1254 | ||
| 1226 | 1255 | def check_has_stable_libuuid_extractable_node(self): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments