]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Move test data to data
authorŁukasz Langa <lukasz@langa.pl>
Wed, 6 Jun 2018 22:39:58 +0000 (15:39 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Wed, 6 Jun 2018 22:48:38 +0000 (15:48 -0700)
37 files changed:
tests/data/cantfit.py [moved from tests/cantfit.py with 100% similarity]
tests/data/class_blank_parentheses.py [moved from tests/class_blank_parentheses.py with 100% similarity]
tests/data/class_methods_new_line.py [moved from tests/class_methods_new_line.py with 100% similarity]
tests/data/comments.py [moved from tests/comments.py with 100% similarity]
tests/data/comments2.py [moved from tests/comments2.py with 100% similarity]
tests/data/comments3.py [moved from tests/comments3.py with 100% similarity]
tests/data/comments4.py [moved from tests/comments4.py with 100% similarity]
tests/data/comments5.py [moved from tests/comments5.py with 100% similarity]
tests/data/composition.py [moved from tests/composition.py with 100% similarity]
tests/data/debug_visitor.out [moved from tests/debug_visitor.out with 100% similarity]
tests/data/debug_visitor.py [moved from tests/debug_visitor.py with 100% similarity]
tests/data/empty_lines.py [moved from tests/empty_lines.py with 100% similarity]
tests/data/expression.diff [moved from tests/expression.diff with 100% similarity]
tests/data/expression.py [moved from tests/expression.py with 100% similarity]
tests/data/fmtonoff.py [moved from tests/fmtonoff.py with 100% similarity]
tests/data/force_py36.py [moved from tests/force_py36.py with 100% similarity]
tests/data/force_pyi.py [moved from tests/force_pyi.py with 100% similarity]
tests/data/fstring.py [moved from tests/fstring.py with 100% similarity]
tests/data/function.py [moved from tests/function.py with 100% similarity]
tests/data/function2.py [moved from tests/function2.py with 100% similarity]
tests/data/import_spacing.py [moved from tests/import_spacing.py with 100% similarity]
tests/data/include_exclude_tests/b/.definitely_exclude/a.pie [moved from tests/include_exclude_tests/b/.definitely_exclude/a.pie with 100% similarity]
tests/data/include_exclude_tests/b/.definitely_exclude/a.py [moved from tests/include_exclude_tests/b/.definitely_exclude/a.py with 100% similarity]
tests/data/include_exclude_tests/b/.definitely_exclude/a.pyi [moved from tests/include_exclude_tests/b/.definitely_exclude/a.pyi with 100% similarity]
tests/data/include_exclude_tests/b/dont_exclude/a.pie [moved from tests/include_exclude_tests/b/dont_exclude/a.pie with 100% similarity]
tests/data/include_exclude_tests/b/dont_exclude/a.py [moved from tests/include_exclude_tests/b/dont_exclude/a.py with 100% similarity]
tests/data/include_exclude_tests/b/dont_exclude/a.pyi [moved from tests/include_exclude_tests/b/dont_exclude/a.pyi with 100% similarity]
tests/data/include_exclude_tests/b/exclude/a.pie [moved from tests/include_exclude_tests/b/exclude/a.pie with 100% similarity]
tests/data/include_exclude_tests/b/exclude/a.py [moved from tests/include_exclude_tests/b/exclude/a.py with 100% similarity]
tests/data/include_exclude_tests/b/exclude/a.pyi [moved from tests/include_exclude_tests/b/exclude/a.pyi with 100% similarity]
tests/data/python2.py [moved from tests/python2.py with 100% similarity]
tests/data/python2_unicode_literals.py [moved from tests/python2_unicode_literals.py with 100% similarity]
tests/data/slices.py [moved from tests/slices.py with 100% similarity]
tests/data/string_prefixes.py [moved from tests/string_prefixes.py with 100% similarity]
tests/data/string_quotes.py [moved from tests/string_quotes.py with 100% similarity]
tests/data/stub.pyi [moved from tests/stub.pyi with 100% similarity]
tests/test_black.py

similarity index 100%
rename from tests/cantfit.py
rename to tests/data/cantfit.py
similarity index 100%
rename from tests/comments.py
rename to tests/data/comments.py
similarity index 100%
rename from tests/comments2.py
rename to tests/data/comments2.py
similarity index 100%
rename from tests/comments3.py
rename to tests/data/comments3.py
similarity index 100%
rename from tests/comments4.py
rename to tests/data/comments4.py
similarity index 100%
rename from tests/comments5.py
rename to tests/data/comments5.py
similarity index 100%
rename from tests/expression.py
rename to tests/data/expression.py
similarity index 100%
rename from tests/fmtonoff.py
rename to tests/data/fmtonoff.py
similarity index 100%
rename from tests/force_py36.py
rename to tests/data/force_py36.py
similarity index 100%
rename from tests/force_pyi.py
rename to tests/data/force_pyi.py
similarity index 100%
rename from tests/fstring.py
rename to tests/data/fstring.py
similarity index 100%
rename from tests/function.py
rename to tests/data/function.py
similarity index 100%
rename from tests/function2.py
rename to tests/data/function2.py
similarity index 100%
rename from tests/python2.py
rename to tests/data/python2.py
similarity index 100%
rename from tests/slices.py
rename to tests/data/slices.py
similarity index 100%
rename from tests/stub.pyi
rename to tests/data/stub.pyi
index 1271290d9497244b041efba17987800fb33f2cc3..e555ba96c4bed56967ef811db8e998895d6c0f17 100644 (file)
@@ -31,13 +31,14 @@ def dump_to_stderr(*output: str) -> str:
     return "\n" + "\n".join(output) + "\n"
 
 
-def read_data(name: str) -> Tuple[str, str]:
+def read_data(name: str, data: bool = True) -> Tuple[str, str]:
     """read_data('test_name') -> 'input', 'output'"""
     if not name.endswith((".py", ".pyi", ".out", ".diff")):
         name += ".py"
     _input: List[str] = []
     _output: List[str] = []
-    with open(THIS_DIR / name, "r", encoding="utf8") as test:
+    base_dir = THIS_DIR / "data" if data else THIS_DIR
+    with open(base_dir / name, "r", encoding="utf8") as test:
         lines = test.readlines()
     result = _input
     for line in lines:
@@ -141,7 +142,7 @@ class BlackTestCase(unittest.TestCase):
 
     @patch("black.dump_to_file", dump_to_stderr)
     def test_self(self) -> None:
-        source, expected = read_data("test_black")
+        source, expected = read_data("test_black", data=False)
         actual = fs(source)
         self.assertFormatEqual(expected, actual)
         black.assert_equivalent(source, actual)
@@ -150,7 +151,7 @@ class BlackTestCase(unittest.TestCase):
 
     @patch("black.dump_to_file", dump_to_stderr)
     def test_black(self) -> None:
-        source, expected = read_data("../black")
+        source, expected = read_data("../black", data=False)
         actual = fs(source)
         self.assertFormatEqual(expected, actual)
         black.assert_equivalent(source, actual)
@@ -158,7 +159,7 @@ class BlackTestCase(unittest.TestCase):
         self.assertFalse(ff(THIS_DIR / ".." / "black.py"))
 
     def test_piping(self) -> None:
-        source, expected = read_data("../black")
+        source, expected = read_data("../black", data=False)
         stderrbuf = BytesIO()
         result = BlackRunner(stderrbuf).invoke(
             black.main, ["-", "--fast", f"--line-length={ll}"], input=source
@@ -186,7 +187,7 @@ class BlackTestCase(unittest.TestCase):
 
     @patch("black.dump_to_file", dump_to_stderr)
     def test_setup(self) -> None:
-        source, expected = read_data("../setup")
+        source, expected = read_data("../setup", data=False)
         actual = fs(source)
         self.assertFormatEqual(expected, actual)
         black.assert_equivalent(source, actual)
@@ -931,14 +932,14 @@ class BlackTestCase(unittest.TestCase):
     def test_check_diff_use_together(self) -> None:
         with cache_dir():
             # Files which will be reformatted.
-            src1 = (THIS_DIR / "string_quotes.py").resolve()
+            src1 = (THIS_DIR / "data" / "string_quotes.py").resolve()
             result = CliRunner().invoke(black.main, [str(src1), "--diff", "--check"])
-            self.assertEqual(result.exit_code, 1)
+            self.assertEqual(result.exit_code, 1, result.output)
 
             # Files which will not be reformatted.
-            src2 = (THIS_DIR / "composition.py").resolve()
+            src2 = (THIS_DIR / "data" / "composition.py").resolve()
             result = CliRunner().invoke(black.main, [str(src2), "--diff", "--check"])
-            self.assertEqual(result.exit_code, 0)
+            self.assertEqual(result.exit_code, 0, result.output)
 
             # Multi file command.
             result = CliRunner().invoke(
@@ -1080,14 +1081,14 @@ class BlackTestCase(unittest.TestCase):
         self.assertFormatEqual(actual, expected)
 
     def test_include_exclude(self) -> None:
-        path = THIS_DIR / "include_exclude_tests"
+        path = THIS_DIR / "data" / "include_exclude_tests"
         include = re.compile(r"\.pyi?$")
         exclude = re.compile(r"/exclude/|/\.definitely_exclude/")
         report = black.Report()
         sources: List[Path] = []
         expected = [
-            Path(THIS_DIR / "include_exclude_tests/b/dont_exclude/a.py"),
-            Path(THIS_DIR / "include_exclude_tests/b/dont_exclude/a.pyi"),
+            Path(path / "b/dont_exclude/a.py"),
+            Path(path / "b/dont_exclude/a.pyi"),
         ]
         this_abs = THIS_DIR.resolve()
         sources.extend(
@@ -1096,7 +1097,7 @@ class BlackTestCase(unittest.TestCase):
         self.assertEqual(sorted(expected), sorted(sources))
 
     def test_empty_include(self) -> None:
-        path = THIS_DIR / "include_exclude_tests"
+        path = THIS_DIR / "data" / "include_exclude_tests"
         report = black.Report()
         empty = re.compile(r"")
         sources: List[Path] = []
@@ -1120,7 +1121,7 @@ class BlackTestCase(unittest.TestCase):
         self.assertEqual(sorted(expected), sorted(sources))
 
     def test_empty_exclude(self) -> None:
-        path = THIS_DIR / "include_exclude_tests"
+        path = THIS_DIR / "data" / "include_exclude_tests"
         report = black.Report()
         empty = re.compile(r"")
         sources: List[Path] = []