2022.6 #88

Merged
edraft merged 158 commits from 2022.6 into master 2022-06-29 17:50:07 +02:00
3 changed files with 23 additions and 8 deletions
Showing only changes of commit 9e978f3ece - Show all commits

View File

@ -1,6 +1,8 @@
import json
import os
import shutil
import subprocess
import sys
import unittest
import pkg_resources
@ -44,6 +46,10 @@ class InstallTestCase(unittest.TestCase):
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()])
def test_install_package(self):
version = '1.7.3'
package_name = 'discord.py'
@ -57,11 +63,11 @@ class InstallTestCase(unittest.TestCase):
package,
settings['ProjectSettings']['Dependencies']
)
packages = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
packages = self._get_installed_packages()
self.assertIn(package_name, packages)
self.assertEqual(version, packages[package_name])
def test_install_all(self):
def _test_install_all(self):
version = '1.7.3'
package_name = 'discord.py'
package = f'{package_name}=={version}'
@ -83,5 +89,8 @@ class InstallTestCase(unittest.TestCase):
package,
new_settings['ProjectSettings']['Dependencies']
)
packages = self._get_installed_packages()
self.assertIn(package_name, packages)
self.assertEqual(version, packages[package_name])

View File

@ -1,13 +1,11 @@
import json
import os
import shutil
import time
import subprocess
import sys
import unittest
import pkg_resources
from cpl_core.utils import String
from unittests_cli.constants import PLAYGROUND_PATH
from unittests_shared.cli_commands import CLICommands
@ -44,6 +42,10 @@ class UninstallTestCase(unittest.TestCase):
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()])
def test_uninstall(self):
CLICommands.uninstall(self._package)
settings = self._get_project_settings()
@ -54,5 +56,5 @@ class UninstallTestCase(unittest.TestCase):
self._package,
settings['ProjectSettings']['Dependencies']
)
packages = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
packages = self._get_installed_packages()
self.assertNotIn(self._package_name, packages)

View File

@ -30,7 +30,11 @@ class CLICommands:
cls._run('generate', schematic, name, output=output)
@classmethod
def install(cls, package: str = '', output=False):
def install(cls, package: str = None, output=False):
if package is None:
cls._run('install', output=output)
return
cls._run('install', package, output=output)
@classmethod