Beispiel #1
0
    def test_sub_python_is_this_python(self):
        # Try it with a Python command.
        self.set_environ('COV_FOOBAR', 'XYZZY')
        self.make_file(
            "showme.py", """\
            import os, sys
            print(sys.executable)
            print(os.__file__)
            print(os.environ['COV_FOOBAR'])
            """)
        out = self.run_command("python showme.py").splitlines()
        self.assertEqual(actual_path(out[0]), actual_path(sys.executable))
        self.assertEqual(out[1], os.__file__)
        self.assertEqual(out[2], 'XYZZY')

        # Try it with a "coverage debug sys" command.
        out = self.run_command("coverage debug sys")

        executable = re_line(out, "executable:")
        executable = executable.split(":", 1)[1].strip()
        self.assertTrue(_same_python_executable(executable, sys.executable))

        # "environment: COV_FOOBAR = XYZZY" or "COV_FOOBAR = XYZZY"
        environ = re_line(out, "COV_FOOBAR")
        _, _, environ = environ.rpartition(":")
        self.assertEqual(environ.strip(), "COV_FOOBAR = XYZZY")
Beispiel #2
0
    def test_sub_python_is_this_python(self):
        # Try it with a Python command.
        self.set_environ('COV_FOOBAR', 'XYZZY')
        self.make_file("showme.py", """\
            import os, sys
            print(sys.executable)
            print(os.__file__)
            print(os.environ['COV_FOOBAR'])
            """)
        out = self.run_command("python showme.py").splitlines()
        self.assertEqual(actual_path(out[0]), actual_path(sys.executable))
        self.assertEqual(out[1], os.__file__)
        self.assertEqual(out[2], 'XYZZY')

        # Try it with a "coverage debug sys" command.
        out = self.run_command("coverage debug sys")

        executable = re_line(out, "executable:")
        executable = executable.split(":", 1)[1].strip()
        self.assertTrue(_same_python_executable(executable, sys.executable))

        # "environment: COV_FOOBAR = XYZZY" or "COV_FOOBAR = XYZZY"
        environ = re_line(out, "COV_FOOBAR")
        _, _, environ = environ.rpartition(":")
        self.assertEqual(environ.strip(), "COV_FOOBAR = XYZZY")
Beispiel #3
0
 def test_canonical_filename_ensure_cache_hit(self):
     self.make_file("sub/proj1/file1.py")
     d = actual_path(self.abs_path("sub/proj1"))
     os.chdir(d)
     files.set_relative_directory()
     canonical_path = files.canonical_filename('sub/proj1/file1.py')
     assert canonical_path == self.abs_path('file1.py')
     # After the filename has been converted, it should be in the cache.
     assert 'sub/proj1/file1.py' in files.CANONICAL_FILENAME_CACHE
     assert files.canonical_filename('sub/proj1/file1.py') == self.abs_path('file1.py')
Beispiel #4
0
 def test_canonical_filename_ensure_cache_hit(self):
     self.make_file("sub/proj1/file1.py")
     d = actual_path(self.abs_path("sub/proj1"))
     self.chdir(d)
     files.set_relative_directory()
     canonical_path = files.canonical_filename('sub/proj1/file1.py')
     self.assertEqual(canonical_path, self.abs_path('file1.py'))
     # After the filename has been converted, it should be in the cache.
     self.assertIn('sub/proj1/file1.py', files.CANONICAL_FILENAME_CACHE)
     self.assertEqual(
         files.canonical_filename('sub/proj1/file1.py'),
         self.abs_path('file1.py'))
Beispiel #5
0
 def test_actual_path(self):
     self.assertEquals(actual_path(r'c:\Windows'), actual_path(r'C:\wINDOWS'))
Beispiel #6
0
 def test_actual_path(self):
     self.assertEqual(actual_path(r'c:\Windows'),
                      actual_path(r'C:\wINDOWS'))
Beispiel #7
0
 def test_actual_path(self):
     assert actual_path(r'c:\Windows') == actual_path(r'C:\wINDOWS')