test(history): support Python 3.10 package fixture cleanup (#209)
This commit is contained in:
@@ -4,6 +4,7 @@ ComfyUI serves every .js file under WEB_DIRECTORY into the canvas page, so the
|
||||
directory must hold nothing but the node extension.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -26,7 +27,9 @@ class TestExtensionWebDir(unittest.TestCase):
|
||||
cls.addClassCleanup(cls.tmp.cleanup)
|
||||
output_dir = os.path.join(cls.tmp.name, "output")
|
||||
os.makedirs(output_dir)
|
||||
cls.package, _ = cls.enterClassContext(
|
||||
package_context = contextlib.ExitStack()
|
||||
cls.addClassCleanup(package_context.close)
|
||||
cls.package, _ = package_context.enter_context(
|
||||
load_package(
|
||||
cls.package_name, os.path.join(cls.tmp.name, "prompts.db"), output_dir
|
||||
)
|
||||
|
||||
@@ -191,7 +191,9 @@ class PackageTestCase(unittest.TestCase):
|
||||
cls.output_dir = os.path.join(cls.tmp.name, "output")
|
||||
os.makedirs(cls.output_dir)
|
||||
cls.db_path = cls.make_db_path(cls.tmp.name)
|
||||
cls.package, cls.server = cls.enterClassContext(
|
||||
package_context = contextlib.ExitStack()
|
||||
cls.addClassCleanup(package_context.close)
|
||||
cls.package, cls.server = package_context.enter_context(
|
||||
load_package(
|
||||
cls.package_name, cls.db_path, cls.output_dir, server=cls.make_server()
|
||||
)
|
||||
@@ -350,8 +352,10 @@ class TestConsoleBanner(unittest.TestCase):
|
||||
name = "prompt_manager_pkg_cp1252"
|
||||
stream = io.TextIOWrapper(io.BytesIO(), encoding="cp1252", errors="strict")
|
||||
|
||||
package_context = contextlib.ExitStack()
|
||||
self.addCleanup(package_context.close)
|
||||
with contextlib.redirect_stdout(stream):
|
||||
package, _ = self.enterContext(
|
||||
package, _ = package_context.enter_context(
|
||||
load_package(name, os.path.join(tmp.name, "p.db"), output_dir)
|
||||
)
|
||||
self.addCleanup(sys.modules.pop, name, None)
|
||||
|
||||
Reference in New Issue
Block a user