def test_analyze_coverage(self) -> None: fake_setup_py = Path("unittest/setup.py") fake_venv_path = self.loop.run_until_complete( ptr.create_venv("https://pypi.com/s", install_pkgs=False)) self.assertIsNone( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {}, "")) self.assertIsNone( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {"bla": 69}, "")) # Test with simple py_modules self.assertEqual( ptr._analyze_coverage( fake_venv_path, fake_setup_py, ptr_tests_fixtures.FAKE_REQ_COVERAGE, ptr_tests_fixtures.SAMPLE_REPORT_OUTPUT, ), ptr_tests_fixtures.EXPECTED_COVERAGE_FAIL_RESULT, ) # Test with venv installed modules self.assertEqual( ptr._analyze_coverage( fake_venv_path, fake_setup_py, ptr_tests_fixtures.FAKE_TG_REQ_COVERAGE, ptr_tests_fixtures.SAMPLE_TG_REPORT_OUTPUT, ), ptr_tests_fixtures.EXPECTED_PTR_COVERAGE_FAIL_RESULT, ) rmtree(fake_venv_path)
def test_analyze_coverage(self, mock_log: Mock, mock_time: Mock) -> None: mock_time.return_value = 0 fake_setup_py = Path("unittest/setup.py") if "VIRTUAL_ENV" in environ: fake_venv_path = Path(environ["VIRTUAL_ENV"]) else: fake_venv_path = self.loop.run_until_complete( ptr.create_venv("https://pypi.com/s", install_pkgs=False)) self.assertIsNone( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {}, "", {}, 0)) self.assertIsNone( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {"bla": 69}, "", {}, 0)) # Test with simple py_modules self.assertEqual( ptr._analyze_coverage( fake_venv_path, fake_setup_py, ptr_tests_fixtures.FAKE_REQ_COVERAGE, ptr_tests_fixtures.SAMPLE_REPORT_OUTPUT, {}, 0, ), ptr_tests_fixtures.EXPECTED_COVERAGE_FAIL_RESULT, ) # Test with venv installed modules cov_report = (ptr_tests_fixtures.SAMPLE_WIN_TG_REPORT_OUTPUT if ptr.WINDOWS else ptr_tests_fixtures.SAMPLE_NIX_TG_REPORT_OUTPUT) self.assertEqual( ptr._analyze_coverage( fake_venv_path, fake_setup_py, ptr_tests_fixtures.FAKE_TG_REQ_COVERAGE, cov_report, {}, 0, ), ptr_tests_fixtures.EXPECTED_PTR_COVERAGE_FAIL_RESULT, ) # Test we error on non existent files with coverage requirements self.assertEqual( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {"fake_file.py": 48}, cov_report, {}, 0), ptr_tests_fixtures.EXPECTED_PTR_COVERAGE_MISSING_FILE_RESULT, ) self.assertTrue(mock_log.called) # Dont delete the VIRTUAL_ENV carrying the test if we didn't make it if "VIRTUAL_ENV" not in environ: rmtree(fake_venv_path)
def test_analyze_coverage(self) -> None: fake_setup_py = Path("unittest/setup.py") if "VIRTUAL_ENV" in environ: fake_venv_path = Path(environ["VIRTUAL_ENV"]) else: fake_venv_path = self.loop.run_until_complete( ptr.create_venv("https://pypi.com/s", install_pkgs=False)) self.assertIsNone( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {}, "", {})) self.assertIsNone( ptr._analyze_coverage(fake_venv_path, fake_setup_py, {"bla": 69}, "", {})) # Test with simple py_modules self.assertEqual( ptr._analyze_coverage( fake_venv_path, fake_setup_py, ptr_tests_fixtures.FAKE_REQ_COVERAGE, ptr_tests_fixtures.SAMPLE_REPORT_OUTPUT, {}, ), ptr_tests_fixtures.EXPECTED_COVERAGE_FAIL_RESULT, ) # Test with venv installed modules cov_report = (ptr_tests_fixtures.SAMPLE_WIN_TG_REPORT_OUTPUT if ptr.WINDOWS else ptr_tests_fixtures.SAMPLE_NIX_TG_REPORT_OUTPUT) self.assertEqual( ptr._analyze_coverage( fake_venv_path, fake_setup_py, ptr_tests_fixtures.FAKE_TG_REQ_COVERAGE, cov_report, {}, ), ptr_tests_fixtures.EXPECTED_PTR_COVERAGE_FAIL_RESULT, ) # Dont delete the VIRTUAL_ENV carrying the test if we didn't make it if "VIRTUAL_ENV" not in environ: rmtree(fake_venv_path)
def test_create_venv_site_packages(self, mock_pip_mirror: Mock) -> None: self.loop.run_until_complete( ptr.create_venv("https://pip.com/", install_pkgs=False, system_site_packages=True))
def test_create_venv(self, mock_pip_mirror: Mock) -> None: self.assertTrue( isinstance( self.loop.run_until_complete( ptr.create_venv("https://pip.com/")), Path))