test_utils.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. from click.testing import CliRunner
  3. from mim.commands.install import cli as install
  4. from mim.commands.uninstall import cli as uninstall
  5. from mim.utils import get_github_url, parse_home_page
  6. def setup_module():
  7. runner = CliRunner()
  8. result = runner.invoke(uninstall, ['mmcv-full', '--yes'])
  9. assert result.exit_code == 0
  10. result = runner.invoke(uninstall, ['mmcls', '--yes'])
  11. assert result.exit_code == 0
  12. def test_parse_home_page():
  13. runner = CliRunner()
  14. result = runner.invoke(install, ['mmcls', '--yes'])
  15. assert result.exit_code == 0
  16. assert parse_home_page(
  17. 'mmcls') == 'https://github.com/open-mmlab/mmclassification'
  18. result = runner.invoke(uninstall, ['mmcls', '--yes'])
  19. assert result.exit_code == 0
  20. def test_get_github_url():
  21. runner = CliRunner()
  22. result = runner.invoke(install, ['mmcls', '--yes'])
  23. assert result.exit_code == 0
  24. assert get_github_url(
  25. 'mmcls') == 'https://github.com/open-mmlab/mmclassification.git'
  26. result = runner.invoke(uninstall, ['mmcls', '--yes'])
  27. assert result.exit_code == 0
  28. assert get_github_url(
  29. 'mmcls') == 'https://github.com/open-mmlab/mmclassification.git'
  30. def teardown_module():
  31. runner = CliRunner()
  32. result = runner.invoke(uninstall, ['mmcv-full', '--yes'])
  33. assert result.exit_code == 0
  34. result = runner.invoke(uninstall, ['mmcls', '--yes'])
  35. assert result.exit_code == 0