okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-ci-green-0215: the four red GitHub checks (cmake-cpu on MSVC, py-tools on a CRLF checkout and on macOS, the Windows snapshot time)b749503db

main
21.2 KiB374 linesraw
1"""Tests for image generation's setup side (tools/image/qimage.py, setup.py --images): the pins, the quant and backend
2choices, the CMake definitions, the source unpacking and the run config's "images" section.  No GPU, no network.
3
4    python -m unittest tools.test_qimage
5"""
6from __future__ import annotations
7
8import argparse
9import contextlib
10import io
11import json
12import re
13import sys
14import tempfile
15import unittest
16import zipfile
17from pathlib import Path
18from unittest import mock
19
20ROOT = Path(__file__).resolve().parents[1]
21sys.path.insert(0, str(ROOT))
22sys.path.insert(0, str(ROOT / "tools"))
23sys.path.insert(0, str(ROOT / "tools" / "image"))
24import qimage as QI  # noqa: E402
25import setup  # noqa: E402
26
27
28def quiet(fn, *args, **kw):
29    with contextlib.redirect_stdout(io.StringIO()):
30        return fn(*args, **kw)
31
32
33class Pins(unittest.TestCase):
34    def test_shapes(self):
35        for c in (QI.SD_CPP_COMMIT, QI.SD_GGML_COMMIT, *QI.REVISIONS.values()):
36            self.assertRegex(c, r"^[0-9a-f]{40}$")
37        for name, (repo, path, size, sha) in QI.FILES.items():
38            self.assertIn(repo, QI.REVISIONS, name)
39            self.assertRegex(sha, r"^[0-9a-f]{64}$")
40            self.assertGreater(size, 100 << 20)
41        self.assertEqual(QI.file_url("Q8_0"), "https://huggingface.co/unsloth/Qwen-Image-2.1-Turbo-GGUF/resolve/"
42                         "5d1f9f759ea877ae556cda88dbec958b62ad3809/qwen-image-2.1-turbo-Q8_0.gguf")
43        self.assertEqual(QI.local_path(Path("m"), "vae"),
44                         Path("m") / "qwen-image-2.1-turbo" / "qwen_image_2.1_vae_bf16.safetensors")
45
46    def test_sigmas_are_the_models(self):
47        """serve/images.py's schedule is model_index.json's sample_sigmas plus the terminal 0."""
48        from serve import images
49        sample = [1.0, 0.978453, 0.95418, 0.926626, 0.89508, 0.845148, 0.704534, 0.414568]
50        self.assertEqual([float(x) for x in images.TURBO_SIGMAS.split(",")], sample + [0.0])
51
52
53class Choices(unittest.TestCase):
54    def test_quant_by_memory(self):
55        self.assertEqual([QI.pick_quant(g) for g in (4, 8, 8.5, 12, 12.1, 16, 32)],
56                         ["Q4_K_M", "Q4_K_M", "Q6_K", "Q6_K", "Q8_0", "Q8_0", "Q8_0"])
57
58    def test_backend(self):
59        self.assertEqual(QI.pick_backend(None, False), "cpu")
60        self.assertEqual(QI.pick_backend({"vendor": "nvidia"}, True), "cuda")
61        self.assertEqual(QI.pick_backend({"vendor": "amd"}, False), "hip")
62        self.assertEqual(QI.pick_backend({"vendor": "amd", "uma": True}, False), "vulkan")    # the 780M, Strix Halo
63        self.assertEqual(QI.pick_backend({"vendor": "amd"}, True), "vulkan")                  # AMD on Windows
64        self.assertEqual(QI.pick_backend({"vendor": "intel"}, False), "vulkan")
65        self.assertEqual(QI.pick_backend({"vendor": "amd", "arch": "gfx1103"}, False), "vulkan")   # no uma mark
66        self.assertEqual(QI.pick_backend({"vendor": "amd", "arch": "gfx1100"}, False), "hip")
67        self.assertTrue(QI.is_apu({"arch": "gfx1151:xnack-"}))
68
69    def test_default_args(self):
70        self.assertEqual(QI.default_args("cuda"), ["--diffusion-fa"])
71        self.assertEqual(QI.default_args("vulkan"), ["--diffusion-fa", "--vae-tiling", "--vae-tile-overlap", "0.25"])
72
73    def test_setup_recommends_never_forces(self):
74        ns = argparse.Namespace(image_backend=None, image_quant=None)
75        self.assertEqual(quiet(setup.image_backend_choice, ns, {"vram_gb": 12.0, "arch": 86}, False)[:2],
76                         ("cuda", "Q6_K"))
77        self.assertEqual(quiet(setup.image_backend_choice, ns, {"vram_gb": 32.3, "uma": True, "arch": "gfx1103"},
78                               True)[:2], ("vulkan", "Q8_0"))
79        ns.image_quant = "Q8_0"                      # more than recommended: kept, with a warning
80        out = io.StringIO()
81        with contextlib.redirect_stdout(out):
82            r = setup.image_backend_choice(ns, {"vram_gb": 8.0, "arch": 86}, False)
83        self.assertEqual(r[:2], ("cuda", "Q8_0"))
84        self.assertIn("recommends Q4_K_M", out.getvalue())
85        ns.image_quant, ns.image_backend = None, "cpu"
86        self.assertEqual(quiet(setup.image_backend_choice, ns, {"vram_gb": 24.0}, False)[:2], ("cpu", "Q4_K_M"))
87
88
89class Build(unittest.TestCase):
90    def test_cmake_defs(self):
91        d = QI.cmake_defs("cuda", arch=86, cuda_root=Path("/usr/local/cuda"))
92        self.assertIn("-DSD_CUDA=ON", d)
93        self.assertIn("-DCMAKE_CUDA_ARCHITECTURES=86", d)
94        self.assertIn("-DSD_WEBP=OFF", d)
95        self.assertIn("-DSD_VULKAN=ON", QI.cmake_defs("vulkan"))
96        with tempfile.TemporaryDirectory() as r:
97            rocm = Path(r)
98            (rocm / "lib" / "llvm" / "bin").mkdir(parents=True)
99            d = QI.cmake_defs("hip", arch="gfx1103:sramecc-:xnack-", rocm=rocm)
100            self.assertIn("-DGPU_TARGETS=gfx1103", d)
101            self.assertIn(f"-DCMAKE_HIP_COMPILER={rocm / 'lib' / 'llvm' / 'bin' / 'clang++'}", d)
102        with self.assertRaises(ValueError):
103            QI.cmake_defs("hip", arch="gfx1103")
104        with self.assertRaises(ValueError):
105            QI.cmake_defs("metal")
106
107    def test_unpack_puts_ggml_in_place(self):
108        with tempfile.TemporaryDirectory() as d:
109            d = Path(d)
110            z1, z2 = d / "sd.zip", d / "ggml.zip"
111            with zipfile.ZipFile(z1, "w") as z:
112                z.writestr(f"stable-diffusion.cpp-{QI.SD_CPP_COMMIT}/CMakeLists.txt", "project(sd)")
113                z.writestr(f"stable-diffusion.cpp-{QI.SD_CPP_COMMIT}/ggml/", "")
114            with zipfile.ZipFile(z2, "w") as z:
115                z.writestr(f"ggml-{QI.SD_GGML_COMMIT}/CMakeLists.txt", "project(ggml)")
116            src = QI.unpack_source(d, z1, z2)
117            self.assertEqual((src / "ggml" / "CMakeLists.txt").read_text(), "project(ggml)")
118            self.assertTrue(QI.source_ok(src))
119            (src / ".strata-pin").write_text("0" * 40 + "\n" + QI.SD_GGML_COMMIT + "\n")
120            self.assertFalse(QI.source_ok(src))          # another pin: unpacked again
121
122    def test_build_is_skipped_when_the_stamp_matches(self):
123        with tempfile.TemporaryDirectory() as d, mock.patch.object(setup, "IMAGE_ENGINE", Path(d)):
124            (Path(d) / QI.SD_EXE).write_bytes(b"x")
125            (Path(d) / "BUILD.json").write_text(json.dumps({**QI.build_stamp("cuda", 86), "lib_dirs": [d]}))
126            with mock.patch.object(setup, "cmake_build") as cb:
127                exe, libs = quiet(setup.build_image_engine, "cuda", {"arch": 86})
128            cb.assert_not_called()
129            self.assertEqual((exe, libs), (Path(d) / QI.SD_EXE, [d]))
130            with mock.patch.object(setup, "cmake_build") as cb, mock.patch.object(setup, "get_sd_cpp"), \
131                    mock.patch.object(setup, "apply_native_runner"), \
132                    mock.patch.object(setup, "find_nvcc", return_value=(None, None)):
133                with self.assertRaises(SystemExit):     # another arch: compiled again (here: no nvcc, so it stops)
134                    quiet(setup.build_image_engine, "cuda", {"arch": 89})
135
136
137class Config(unittest.TestCase):
138    def test_section(self):
139        c = QI.image_config("vulkan", "Q8_0", Path("/e/sd-cli"), Path("/m"), uma=True, lib_dirs=["/l"])
140        self.assertEqual(c["diffusion_model"], str(Path("/m/qwen-image-2.1-turbo/qwen-image-2.1-turbo-Q8_0.gguf")))
141        self.assertEqual(c["args"], ["--diffusion-fa", "--vae-tiling", "--vae-tile-overlap", "0.25"])
142        self.assertTrue(c["uma"])
143        self.assertEqual(c["gpu_policy"], "auto")
144        from serve.images import ImageGen
145        with tempfile.TemporaryDirectory() as d:
146            ImageGen({**c, "out_dir": d})              # serve accepts what setup writes
147
148    def test_images_no_drops_the_section(self):
149        with tempfile.TemporaryDirectory() as d:
150            p = Path(d) / "strata-q2_0.json"
151            p.write_text(json.dumps({"exe": "x", "images": {"exe": "sd-cli"}, "mine": 1}))
152            quiet(setup.write_setup_config, p, {"exe": "y", "images": None})
153            cfg = json.loads(p.read_text())
154            self.assertNotIn("images", cfg)
155            self.assertEqual(cfg["mine"], 1)
156            p.write_text(json.dumps({"exe": "x", "images": {"exe": "sd-cli"}}))
157            quiet(setup.write_setup_config, p, {"exe": "y"})      # not asked: carried over
158            self.assertEqual(json.loads(p.read_text())["images"], {"exe": "sd-cli"})
159
160    def test_flags(self):
161        src = (ROOT / "setup.py").read_text(encoding="utf-8")
162        for flag in ("--images", "--image-quant", "--image-backend", "--image-gpu-policy"):
163            self.assertRegex(src, re.escape(f'ap.add_argument("{flag}"'))
164
165
166class Native(unittest.TestCase):
167    """I2: the native DiT runner's patch for the pinned stable-diffusion.cpp, and its config switch."""
168
169    def test_stamp_and_config(self):
170        self.assertIn("native", QI.build_stamp("cuda", 86))
171        self.assertIn("native", QI.build_stamp("hip", "gfx1103"))
172        self.assertNotIn("native", QI.build_stamp("vulkan", None))
173        c = QI.image_config("hip", "Q8_0", Path("/e/sd-cli"), Path("/m"), native=True)
174        self.assertIs(c["native"], True)
175        self.assertNotIn("native", QI.image_config("vulkan", "Q8_0", Path("/e/sd-cli"), Path("/m")))
176
177    def test_apply_is_idempotent(self):
178        sys.path.insert(0, str(QI.NATIVE_DIR))
179        import apply as A
180        with tempfile.TemporaryDirectory() as d:
181            sd = Path(d)
182            (sd / "ggml" / "src" / "ggml-cuda").mkdir(parents=True)
183            (sd / "src" / "model" / "diffusion").mkdir(parents=True)
184            (sd / "src" / "pipeline").mkdir(parents=True)
185            (sd / "src" / "pipeline" / "model_builders.cpp").write_text(
186                "#include <x>\n" + A.INCLUDE_OLD + "int a;\n" + A.BUILDER_OLD + "            }\n", encoding="utf-8")
187            (sd / "CMakeLists.txt").write_text("x\n" + A.CMAKE_OLD + "y\n", encoding="utf-8")
188            A.apply(sd)
189            first = [(sd / f).read_text(encoding="utf-8") for f in ("src/pipeline/model_builders.cpp", "CMakeLists.txt")]
190            A.apply(sd)
191            again = [(sd / f).read_text(encoding="utf-8") for f in ("src/pipeline/model_builders.cpp", "CMakeLists.txt")]
192            self.assertEqual(first, again)
193            self.assertIn("QwenImage21NativeRunner", first[0])
194            self.assertEqual(first[1].count("SD_QI_NATIVE"), 1)
195            self.assertTrue((sd / "ggml/src/ggml-cuda/qi21-native.cu").is_file())
196            (sd / "CMakeLists.txt").write_text("something else\n", encoding="utf-8")
197            with self.assertRaises(SystemExit):        # another sd.cpp: refused, not half-patched
198                A.apply(sd)
199
200
201class Noise(unittest.TestCase):
202    """OWN-5 step 1: Strata's noise generator for sd-cli (tools/image/sdcpp_noise): off by default; nobody compiles
203    again unasked."""
204
205    def test_stamp_without_the_switch_is_what_it_was(self):
206        self.assertEqual(QI.build_stamp("cuda", 86), {"sd_cpp": QI.SD_CPP_COMMIT, "ggml": QI.SD_GGML_COMMIT,
207                                                      "backend": "cuda", "arch": "86", "native": QI.native_hash()})
208        self.assertEqual(QI.build_stamp("vulkan", None), {"sd_cpp": QI.SD_CPP_COMMIT, "ggml": QI.SD_GGML_COMMIT,
209                                                          "backend": "vulkan", "arch": ""})
210        self.assertEqual(QI.build_stamp("cuda", 86, False), QI.build_stamp("cuda", 86))
211
212    def test_stamp_with_the_switch(self):
213        for backend, arch in (("cuda", 86), ("hip", "gfx1103"), ("vulkan", None), ("cpu", None)):
214            s = QI.build_stamp(backend, arch, True)
215            self.assertEqual(s["noise"], QI.noise_hash())
216            self.assertEqual({k: v for k, v in s.items() if k != "noise"}, QI.build_stamp(backend, arch))
217
218    def test_the_native_hash_does_not_move(self):
219        """The noise files live apart from sdcpp_native, so no CUDA / HIP user's sd-cli is rebuilt for them."""
220        self.assertNotEqual(QI.NOISE_DIR, QI.NATIVE_DIR)
221        before = QI.native_hash()
222        with tempfile.TemporaryDirectory() as d:
223            for name in QI.NOISE_FILES:
224                (Path(d) / name).write_bytes((QI.NOISE_DIR / name).read_bytes() + b"changed")
225            with mock.patch.object(QI, "NOISE_DIR", Path(d)):
226                self.assertNotEqual(QI.noise_hash(), before)
227            self.assertEqual(QI.native_hash(), before)
228        self.assertFalse({p.name for p in QI.NATIVE_DIR.iterdir()} & (set(QI.NOISE_FILES) - {"apply.py"}))   # both folders have an apply.py
229
230    def test_noise_hash(self):
231        with tempfile.TemporaryDirectory() as d:
232            for name in QI.NOISE_FILES:
233                (Path(d) / name).write_bytes((QI.NOISE_DIR / name).read_bytes())
234            with mock.patch.object(QI, "NOISE_DIR", Path(d)):
235                h = QI.noise_hash()
236                self.assertRegex(h, r"^[0-9a-f]{16}$")
237                self.assertEqual(h, QI.noise_hash())
238                p = Path(d) / "strata_noise.hpp"
239                p.write_bytes(p.read_bytes().replace(b"\r\n", b"\n").replace(b"\n", b"\r\n"))   # a Windows checkout: the same hash (the file may be CRLF already)
240                self.assertEqual(QI.noise_hash(), h)
241                p.write_bytes(p.read_bytes() + b"// edit\n")
242                self.assertNotEqual(QI.noise_hash(), h)
243        self.assertEqual(QI.noise_hash(), QI.noise_hash())
244
245    def test_config(self):
246        c = QI.image_config("cuda", "Q8_0", Path("/e/sd-cli"), Path("/m"), noise=True)
247        self.assertEqual(c["noise"], "strata")
248        self.assertNotIn("noise", QI.image_config("cuda", "Q8_0", Path("/e/sd-cli"), Path("/m")))
249        from serve.images import ImageGen
250        with tempfile.TemporaryDirectory() as d:
251            ImageGen({**c, "out_dir": d})                # serve accepts what setup writes
252
253    def test_flags(self):
254        self.assertRegex((ROOT / "setup.py").read_text(encoding="utf-8"), re.escape('ap.add_argument("--image-noise"'))
255        self.assertRegex((ROOT / "tools" / "image" / "install.py").read_text(encoding="utf-8"),
256                         re.escape('ap.add_argument("--noise"'))
257
258    def test_build_decisions(self):
259        def stamp_file(d, stamp):
260            (Path(d) / QI.SD_EXE).write_bytes(b"x")
261            (Path(d) / "BUILD.json").write_text(json.dumps({**stamp, "lib_dirs": [d]}))
262        with tempfile.TemporaryDirectory() as d, mock.patch.object(setup, "IMAGE_ENGINE", Path(d)):
263            # a build made before the switch existed: kept when the switch is off, rebuilt with the generator when on
264            stamp_file(d, QI.build_stamp("cuda", 86))
265            with mock.patch.object(setup, "cmake_build") as cb:
266                quiet(setup.build_image_engine, "cuda", {"arch": 86})
267                quiet(setup.build_image_engine, "cuda", {"arch": 86}, False)
268            cb.assert_not_called()
269            with mock.patch.object(setup, "get_sd_cpp"), mock.patch.object(setup, "apply_native_runner"), \
270                    mock.patch.object(setup, "apply_noise_generator") as an, \
271                    mock.patch.object(setup, "find_nvcc", return_value=(None, None)):
272                with self.assertRaises(SystemExit):      # stops at "no nvcc", after the patches
273                    quiet(setup.build_image_engine, "cuda", {"arch": 86}, True)
274            an.assert_called_once()
275            # a build that has the generator: kept with the switch on, kept with it off
276            stamp_file(d, QI.build_stamp("cuda", 86, True))
277            with mock.patch.object(setup, "cmake_build") as cb:
278                quiet(setup.build_image_engine, "cuda", {"arch": 86}, True)
279                quiet(setup.build_image_engine, "cuda", {"arch": 86}, False)
280            cb.assert_not_called()
281            # another arch with the switch off: compiled again, without the generator
282            with mock.patch.object(setup, "get_sd_cpp"), mock.patch.object(setup, "apply_native_runner"), \
283                    mock.patch.object(setup, "apply_noise_generator") as an, \
284                    mock.patch.object(setup, "find_nvcc", return_value=(None, None)):
285                with self.assertRaises(SystemExit):
286                    quiet(setup.build_image_engine, "cuda", {"arch": 89})
287            an.assert_not_called()
288
289
290class VaeDecoder(unittest.TestCase):
291    """OWN-5 step 2: Strata's VAE decoder for sd-cli (tools/image/sdcpp_vae, CUDA / HIP builds): off by default; nobody
292    compiles again unasked; another backend never gets it."""
293
294    def test_stamp_without_the_switch_is_what_it_was(self):
295        for backend, arch in (("cuda", 86), ("hip", "gfx1201"), ("vulkan", None), ("cpu", None)):
296            self.assertEqual(QI.build_stamp(backend, arch, False, False), QI.build_stamp(backend, arch))
297            self.assertNotIn("vae_decoder", QI.build_stamp(backend, arch, True))
298
299    def test_stamp_with_the_switch(self):
300        for backend, arch in (("cuda", 86), ("hip", "gfx1201")):
301            s = QI.build_stamp(backend, arch, False, True)
302            self.assertEqual(s["vae_decoder"], QI.vae_hash())
303            self.assertEqual({k: v for k, v in s.items() if k != "vae_decoder"}, QI.build_stamp(backend, arch))
304            self.assertEqual(QI.build_stamp(backend, arch, True, True)["noise"], QI.noise_hash())
305        for backend in ("vulkan", "cpu"):
306            self.assertEqual(QI.build_stamp(backend, None, False, True), QI.build_stamp(backend, None))
307
308    def test_vae_hash_follows_the_decoder_sources(self):
309        h = QI.vae_hash()
310        self.assertRegex(h, r"^[0-9a-f]{16}$")
311        self.assertEqual(QI.vae_hash(), h)
312        import importlib.util
313        spec = importlib.util.spec_from_file_location("strata_sdcpp_vae_apply_qtest", QI.VAE_DIR / "apply.py")
314        mod = importlib.util.module_from_spec(spec)
315        spec.loader.exec_module(mod)
316        with tempfile.TemporaryDirectory() as d:
317            for src, _ in mod.FILES:
318                (Path(d) / src).parent.mkdir(parents=True, exist_ok=True)
319                (Path(d) / src).write_bytes((ROOT / src).read_bytes())
320            (Path(d) / mod.HIP_COMPAT).mkdir(parents=True, exist_ok=True)
321            for f in (ROOT / mod.HIP_COMPAT).iterdir():
322                (Path(d) / mod.HIP_COMPAT / f.name).write_bytes(f.read_bytes().replace(b"\r\n", b"\n").replace(b"\n", b"\r\n"))   # (CRLF already in a Windows checkout)
323            self.assertEqual(QI.vae_hash(Path(d)), h)                  # a CRLF checkout: the same hash
324            p = Path(d) / "src" / "image" / "vae" / "wan_vae.cu"
325            p.write_bytes(p.read_bytes() + b"// edit\n")
326            self.assertNotEqual(QI.vae_hash(Path(d)), h)
327
328    def test_config(self):
329        c = QI.image_config("cuda", "Q8_0", Path("/e/sd-cli"), Path("/m"), vae=True)
330        self.assertEqual(c["vae_decoder"], "strata")
331        self.assertTrue(c["vae"].endswith("qwen_image_2.1_vae_bf16.safetensors"))      # the file path is untouched
332        self.assertNotIn("vae_decoder", QI.image_config("cuda", "Q8_0", Path("/e/sd-cli"), Path("/m")))
333        self.assertNotIn("vae_decoder", QI.image_config("vulkan", "Q4_K_M", Path("/e/sd-cli"), Path("/m"), vae=True))
334        from serve.images import ImageGen
335        with tempfile.TemporaryDirectory() as d:
336            ImageGen({**c, "out_dir": d})                # serve accepts what setup writes
337
338    def test_flags(self):
339        self.assertRegex((ROOT / "setup.py").read_text(encoding="utf-8"), re.escape('ap.add_argument("--image-vae"'))
340        self.assertIn('warn(f"Strata\'s own picture decoder runs with CUDA or ROCm only; image generation on {backend} keeps "\n'
341                      '             "stable-diffusion.cpp\'s decoder")',
342                      (ROOT / "setup.py").read_text(encoding="utf-8"))     # the owner's wording of 11-11
343        self.assertRegex((ROOT / "tools" / "image" / "install.py").read_text(encoding="utf-8"),
344                         re.escape('ap.add_argument("--vae"'))
345
346    def test_build_decisions(self):
347        def stamp_file(d, stamp):
348            (Path(d) / QI.SD_EXE).write_bytes(b"x")
349            (Path(d) / "BUILD.json").write_text(json.dumps({**stamp, "lib_dirs": [d]}))
350
351        def build_until_nvcc(*args):
352            with mock.patch.object(setup, "get_sd_cpp"), mock.patch.object(setup, "apply_native_runner"), \
353                    mock.patch.object(setup, "apply_noise_generator"), \
354                    mock.patch.object(setup, "apply_vae_decoder") as av, \
355                    mock.patch.object(setup, "find_nvcc", return_value=(None, None)):
356                with self.assertRaises(SystemExit):      # stops at "no nvcc", after the patches
357                    quiet(setup.build_image_engine, *args)
358            return av
359        with tempfile.TemporaryDirectory() as d, mock.patch.object(setup, "IMAGE_ENGINE", Path(d)):
360            stamp_file(d, QI.build_stamp("cuda", 86))           # a build made before the switch existed
361            with mock.patch.object(setup, "cmake_build") as cb:
362                quiet(setup.build_image_engine, "cuda", {"arch": 86}, False, False)
363            cb.assert_not_called()
364            build_until_nvcc("cuda", {"arch": 86}, False, True).assert_called_once()      # switched on: rebuilt
365            stamp_file(d, QI.build_stamp("cuda", 86, False, True))
366            with mock.patch.object(setup, "cmake_build") as cb:
367                quiet(setup.build_image_engine, "cuda", {"arch": 86}, False, True)
368                quiet(setup.build_image_engine, "cuda", {"arch": 86}, False, False)     # off again: kept (inert)
369            cb.assert_not_called()
370            build_until_nvcc("cuda", {"arch": 89}, False, False).assert_not_called()
371
372
373if __name__ == "__main__":
374    unittest.main()