Skip to content

Commit

Permalink
Mark a bunch of tests that don't need temp directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Sep 28, 2013
1 parent 21b7f19 commit b33c041
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tests/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ def test_error(self):
class CmdMainTest(CoverageTest):
"""Tests of coverage.cmdline.main(), using mocking for isolation."""

run_in_temp_dir = False

class CoverageScriptStub(object):
"""A stub for coverage.cmdline.CoverageScript, used by CmdMainTest."""

Expand Down
12 changes: 11 additions & 1 deletion tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,8 @@ def test_try_except_finally(self):
class ModuleTest(CoverageTest):
"""Tests for the module-level behavior of the `coverage` module."""

run_in_temp_dir = False

def test_not_singleton(self):
# You *can* create another coverage object.
coverage.coverage()
Expand All @@ -1705,6 +1707,10 @@ def test_not_singleton(self):
class ReportingTest(CoverageTest):
"""Tests of some reporting behavior."""

# We don't make any temp files, but we need an empty directory to run the
# tests in.
run_in_temp_dir = True

def test_no_data_to_report_on_annotate(self):
# Reporting with no data produces a nice message and no output dir.
self.assertRaisesRegexp(
Expand All @@ -1713,6 +1719,10 @@ def test_no_data_to_report_on_annotate(self):
)
self.assert_doesnt_exist("ann")

# CoverageTest will yell at us for using a temp directory with no files
# made. Instead of adding a way to shut it up, just make a file.
self.make_file("touch.txt", "")

def test_no_data_to_report_on_html(self):
# Reporting with no data produces a nice message and no output dir.
self.assertRaisesRegexp(
Expand All @@ -1727,4 +1737,4 @@ def test_no_data_to_report_on_xml(self):
CoverageException, "No data to report.",
self.command_line, "xml"
)
# Currently, this leaves an empty coverage.xml file... :(
self.assert_doesnt_exist("coverage.xml")
2 changes: 2 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
class DataTest(CoverageTest):
"""Test cases for coverage.data."""

run_in_temp_dir = False

def assert_summary(self, covdata, summary, fullpath=False):
"""Check that the summary of `covdata` is `summary`."""
self.assertEqual(covdata.summary(fullpath), summary)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class InfoFormatterTest(CoverageTest):
"""Tests of misc.info_formatter."""

run_in_temp_dir = False

def test_info_formatter(self):
lines = list(info_formatter([
('x', 'hello there'),
Expand Down
2 changes: 2 additions & 0 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def test_leading_wildcard(self):
class RelativePathAliasesTest(CoverageTest):
"""Tests for coverage/files.py:PathAliases, with relative files."""

run_in_temp_dir = False

def test_dot(self):
for d in ('.', '..', '../other', '~'):
aliases = PathAliases()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_html_delta_from_coverage_version_change(self):
self.assertMultiLineEqual(index1, fixed_index2)


class HtmlTitleTests(HtmlTestHelpers, CoverageTest):
class HtmlTitleTest(HtmlTestHelpers, CoverageTest):
"""Tests of the HTML title support."""

def test_default_title(self):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class HasherTest(CoverageTest):
"""Test our wrapper of md5 hashing."""

run_in_temp_dir = False

def test_string_hashing(self):
h1 = Hasher()
h1.update("Hello, world!")
Expand Down
4 changes: 3 additions & 1 deletion tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,11 @@ def test_fullcoverage(self):
self.assertGreater(data.summary()['os.py'], 50)


class AliasedCommandTests(CoverageTest):
class AliasedCommandTest(CoverageTest):
"""Tests of the version-specific command aliases."""

run_in_temp_dir = False

def test_major_version_works(self):
# "coverage2" works on py2
cmd = "coverage%d" % sys.version_info[0]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def test_empty_files(self):
self.assertIn("tests/modules/pkg2/__init__ 0 0 100%", report)


class ReportingReturnValue(CoverageTest):
class ReportingReturnValueTest(CoverageTest):
"""Tests of reporting functions returning values."""

def run_coverage(self):
Expand Down

0 comments on commit b33c041

Please sign in to comment.