def test_can_highlight_file(self): with tempfile.TemporaryDirectory() as tmp: path = os.path.join(tmp, "foo.py") with open(path, "w") as f: f.write("import unittest\n") f.write("import os.path\n") self.assertEqual( get_annotations(path), [ Annotation(1, 1, 1, 6, {"type": "style", "what": "kn"}), Annotation(1, 8, 1, 15, {"type": "style", "what": "nn"}), Annotation(2, 1, 2, 6, {"type": "style", "what": "kn"}), Annotation(2, 8, 2, 14, {"type": "style", "what": "nn"}), ] )
def test_can_highlight_file(self): with tempfile.TemporaryDirectory() as tmp: path = os.path.join(tmp, "foo.py") with open(path, "w") as f: f.write("import unittest\n") f.write("import os.path\n") self.assertEqual(get_annotations(path), [ Annotation(1, 1, 1, 6, { "type": "style", "what": "kn" }), Annotation(1, 8, 1, 15, { "type": "style", "what": "nn" }), Annotation(2, 1, 2, 6, { "type": "style", "what": "kn" }), Annotation(2, 8, 2, 14, { "type": "style", "what": "nn" }), ])
def _get_annotations(root, name, highlight): return Annotations( get_annotations(os.path.join(root, name)) + _get_highlight_annotations(root, name, highlight) )
def _get_annotations(root, name, highlight): return Annotations( get_annotations(os.path.join(root, name)) + _get_highlight_annotations(root, name, highlight))