2022.12 #133
0
unittests/unittests_cli/abc/__init__.py
Normal file
0
unittests/unittests_cli/abc/__init__.py
Normal file
35
unittests/unittests_cli/abc/command_test_case.py
Normal file
35
unittests/unittests_cli/abc/command_test_case.py
Normal file
@ -0,0 +1,35 @@
|
||||
import os
|
||||
import shutil
|
||||
import traceback
|
||||
import unittest
|
||||
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
|
||||
|
||||
class CommandTestCase(unittest.TestCase):
|
||||
|
||||
def __init__(self, method_name: str):
|
||||
unittest.TestCase.__init__(self, method_name)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
|
||||
|
||||
os.makedirs(PLAYGROUND_PATH)
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
except Exception as e:
|
||||
print(f'Setup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
def setUp(self):
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
|
||||
except Exception as e:
|
||||
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
|
@ -1,18 +1,16 @@
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class AddTestCase(unittest.TestCase):
|
||||
class AddTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'add-test-project'
|
||||
self._target = 'add-test-library'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
@ -26,22 +24,12 @@ class AddTestCase(unittest.TestCase):
|
||||
return project_json
|
||||
|
||||
def setUp(self):
|
||||
if not os.path.exists(PLAYGROUND_PATH):
|
||||
os.makedirs(PLAYGROUND_PATH)
|
||||
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
# create projects
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
CLICommands.new('console', self._target, '--ab', '--s')
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def test_add(self):
|
||||
CLICommands.add(self._source, self._target)
|
||||
settings = self._get_project_settings()
|
||||
|
@ -2,18 +2,17 @@ import filecmp
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class BuildTestCase(unittest.TestCase):
|
||||
class BuildTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'build-test-source'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
|
||||
@ -39,13 +38,6 @@ class BuildTestCase(unittest.TestCase):
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def _are_dir_trees_equal(self, dir1, dir2):
|
||||
"""
|
||||
found at https://stackoverflow.com/questions/4187564/recursively-compare-two-directories-to-ensure-they-have-the-same-files-and-subdi
|
||||
|
@ -76,3 +76,8 @@ class CLITestSuite(unittest.TestSuite):
|
||||
self._setup()
|
||||
self._result = super().run(*args)
|
||||
self._cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
runner = unittest.TextTestRunner()
|
||||
runner.run(CLITestSuite())
|
||||
|
@ -6,4 +6,4 @@ if not os.getcwd().endswith('unittests'):
|
||||
|
||||
PLAYGROUND_PATH = os.path.abspath(os.path.join(os.getcwd(), f'{base}test_cli_playground'))
|
||||
TRANSLATION_PATH = os.path.abspath(os.path.join(os.getcwd(), f'{base}unittests_translation'))
|
||||
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), f'../../src/cpl_cli/main.py'))
|
||||
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), f'{base}../src/cpl_cli/main.py'))
|
||||
|
@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
|
||||
|
||||
class CustomTestCase(unittest.TestCase):
|
||||
class CustomTestCase(CommandTestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
@ -1,17 +1,18 @@
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class GenerateTestCase(unittest.TestCase):
|
||||
class GenerateTestCase(CommandTestCase):
|
||||
_project = 'test-console'
|
||||
_t_path = 'test'
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
CommandTestCase.setUpClass()
|
||||
CLICommands.new('console', cls._project, '--ab', '--s', '--venv')
|
||||
|
||||
def setUp(self):
|
||||
|
@ -6,14 +6,15 @@ import sys
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class InstallTestCase(unittest.TestCase):
|
||||
class InstallTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'install-test-source'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
|
||||
@ -39,13 +40,6 @@ class InstallTestCase(unittest.TestCase):
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def _get_installed_packages(self) -> dict:
|
||||
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
|
||||
return dict([tuple(r.decode().split('==')) for r in reqs.split()])
|
||||
|
@ -1,19 +1,16 @@
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class NewTestCase(unittest.TestCase):
|
||||
class NewTestCase(CommandTestCase):
|
||||
|
||||
def setUp(self):
|
||||
if not os.path.exists(PLAYGROUND_PATH):
|
||||
os.makedirs(PLAYGROUND_PATH)
|
||||
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
|
||||
def _test_project(self, project_type: str, name: str, *args, test_venv=False, without_ws=False):
|
||||
CLICommands.new(project_type, name, *args)
|
||||
@ -73,7 +70,6 @@ class NewTestCase(unittest.TestCase):
|
||||
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, workspace_name, base, String.convert_to_snake_case(name)))
|
||||
self.assertTrue(os.path.exists(project_path))
|
||||
self.assertTrue(os.path.join(project_path, f'{name}.json'))
|
||||
os.chdir(os.path.abspath(os.path.join(os.getcwd(), '../')))
|
||||
|
||||
def _test_sub_directory_project(self, project_type: str, directory: str, name: str, workspace_name: str, *args):
|
||||
os.chdir(os.path.abspath(os.path.join(os.getcwd(), workspace_name)))
|
||||
@ -99,8 +95,6 @@ class NewTestCase(unittest.TestCase):
|
||||
self.assertEqual(build_settings['Main'], f'{String.convert_to_snake_case(name)}.main')
|
||||
self.assertEqual(build_settings['EntryPoint'], name)
|
||||
|
||||
os.chdir(os.path.abspath(os.path.join(os.getcwd(), '../')))
|
||||
|
||||
def test_console(self):
|
||||
self._test_project('console', 'test-console', '--ab', '--s', '--venv', test_venv=True)
|
||||
|
||||
|
@ -5,15 +5,16 @@ import shutil
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class PublishTestCase(unittest.TestCase):
|
||||
class PublishTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'publish-test-source'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
|
||||
@ -39,13 +40,6 @@ class PublishTestCase(unittest.TestCase):
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def _are_dir_trees_equal(self, dir1, dir2):
|
||||
"""
|
||||
found at https://stackoverflow.com/questions/4187564/recursively-compare-two-directories-to-ensure-they-have-the-same-files-and-subdi
|
||||
|
@ -3,14 +3,15 @@ import os
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class RemoveTestCase(unittest.TestCase):
|
||||
class RemoveTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'add-test-project'
|
||||
self._target = 'add-test-library'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
|
@ -1,22 +1,18 @@
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import pkg_resources
|
||||
|
||||
from cpl_core.utils import String
|
||||
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class RunTestCase(unittest.TestCase):
|
||||
class RunTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'run-test'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
self._appsettings = f'src/{String.convert_to_snake_case(self._source)}/appsettings.json'
|
||||
@ -63,13 +59,6 @@ class RunTestCase(unittest.TestCase):
|
||||
file.write(f'\t\t{self._test_code}')
|
||||
file.close()
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def test_run(self):
|
||||
CLICommands.run()
|
||||
settings = self._get_appsettings()
|
||||
|
@ -5,15 +5,16 @@ import time
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_cli.threads.start_test_thread import StartTestThread
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class StartTestCase(unittest.TestCase):
|
||||
class StartTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'start-test'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
self._appsettings = f'src/{String.convert_to_snake_case(self._source)}/appsettings.json'
|
||||
@ -63,13 +64,6 @@ class StartTestCase(unittest.TestCase):
|
||||
file.write(f'\t\t{self._test_code}')
|
||||
file.close()
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def test_start(self):
|
||||
thread = StartTestThread()
|
||||
thread.start()
|
||||
|
@ -6,14 +6,15 @@ import sys
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class UninstallTestCase(unittest.TestCase):
|
||||
class UninstallTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'uninstall-test-source'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
self._version = '1.7.3'
|
||||
@ -31,19 +32,12 @@ class UninstallTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
if not os.path.exists(PLAYGROUND_PATH):
|
||||
os.makedirs(PLAYGROUND_PATH)
|
||||
|
||||
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
# create projects
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def _get_installed_packages(self) -> dict:
|
||||
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
|
||||
return dict([tuple(r.decode().split('==')) for r in reqs.split()])
|
||||
|
@ -6,14 +6,15 @@ import sys
|
||||
import unittest
|
||||
|
||||
from cpl_core.utils import String
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class UpdateTestCase(unittest.TestCase):
|
||||
class UpdateTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._source = 'install-test-source'
|
||||
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||
|
||||
@ -26,6 +27,15 @@ class UpdateTestCase(unittest.TestCase):
|
||||
self._new_package_name = 'discord.py'
|
||||
self._new_package = f'{self._new_package_name}=={self._new_version}'
|
||||
|
||||
def setUp(self):
|
||||
CLICommands.uninstall(self._old_package)
|
||||
CLICommands.uninstall(self._new_package)
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
# create projects
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
CLICommands.install(self._old_package)
|
||||
|
||||
def _get_project_settings(self):
|
||||
with open(os.path.join(os.getcwd(), self._project_file), 'r', encoding='utf-8') as cfg:
|
||||
# load json
|
||||
@ -39,22 +49,6 @@ class UpdateTestCase(unittest.TestCase):
|
||||
project_file.write(json.dumps(settings, indent=2))
|
||||
project_file.close()
|
||||
|
||||
def setUp(self):
|
||||
CLICommands.uninstall(self._old_package)
|
||||
CLICommands.uninstall(self._new_package)
|
||||
os.chdir(os.path.abspath(PLAYGROUND_PATH))
|
||||
# create projects
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
CLICommands.install(self._old_package)
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||
return
|
||||
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||
|
||||
def _get_installed_packages(self) -> dict:
|
||||
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
|
||||
return dict([tuple(r.decode().split('==')) for r in reqs.split()])
|
||||
@ -85,5 +79,3 @@ class UpdateTestCase(unittest.TestCase):
|
||||
packages = self._get_installed_packages()
|
||||
self.assertIn(self._new_package_name, packages)
|
||||
self.assertEqual(self._new_version, packages[self._new_package_name])
|
||||
|
||||
|
||||
|
@ -12,13 +12,14 @@ import cpl_cli
|
||||
from cpl_core.console import ForegroundColorEnum
|
||||
from termcolor import colored
|
||||
|
||||
from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class VersionTestCase(unittest.TestCase):
|
||||
class VersionTestCase(CommandTestCase):
|
||||
|
||||
def __init__(self, methodName: str):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
def __init__(self, method_name: str):
|
||||
CommandTestCase.__init__(self, method_name)
|
||||
self._block_banner = ""
|
||||
self._block_version = ""
|
||||
self._block_package_header = ""
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from unittests_cli.constants import CLI_PATH
|
||||
|
||||
@ -29,7 +30,8 @@ class CLICommands:
|
||||
for arg in args:
|
||||
command.append(arg)
|
||||
|
||||
return subprocess.run(command, env=env_vars, check=True, capture_output=True, text=True).stdout
|
||||
with subprocess.Popen(command, stdout=subprocess.PIPE, universal_newlines=True) as process:
|
||||
return process.stdout.read()
|
||||
|
||||
@classmethod
|
||||
def add(cls, source: str, target: str, output=False):
|
||||
|
@ -1,11 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
import traceback
|
||||
import unittest
|
||||
from typing import Optional
|
||||
from unittest import TestResult
|
||||
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_translation.translation_test_case import TranslationTestCase
|
||||
|
||||
|
||||
@ -25,27 +21,5 @@ class TranslationTestSuite(unittest.TestSuite):
|
||||
for test in active_tests:
|
||||
self.addTests(loader.loadTestsFromTestCase(test))
|
||||
|
||||
def _setup(self):
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
|
||||
|
||||
os.makedirs(PLAYGROUND_PATH)
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
except Exception as e:
|
||||
print(f'Setup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
def _cleanup(self):
|
||||
try:
|
||||
if self._result is not None and (len(self._result.errors) > 0 or len(self._result.failures) > 0):
|
||||
return
|
||||
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH)))
|
||||
except Exception as e:
|
||||
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
def run(self, *args):
|
||||
self._setup()
|
||||
self._result = super().run(*args)
|
||||
self._cleanup()
|
||||
|
Loading…
Reference in New Issue
Block a user