Skip to content

Commit d08c66d

Browse files
committed
Fix tests.
1 parent db462a5 commit d08c66d

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

domdf_python_tools/paths.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,12 @@ def dump_json(
576576
with gzip.open(self, mode="wt", encoding=encoding, errors=errors) as fp:
577577
fp.write(json_library.dumps(data, **kwargs))
578578

579-
self.write_clean(
580-
json_library.dumps(data, **kwargs),
581-
encoding=encoding,
582-
errors=errors,
583-
)
579+
else:
580+
self.write_clean(
581+
json_library.dumps(data, **kwargs),
582+
encoding=encoding,
583+
errors=errors,
584+
)
584585

585586
def load_json(
586587
self,

domdf_python_tools/utils.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@
9292
# this package
9393
import domdf_python_tools.words
9494
from domdf_python_tools import __version__, iterative
95-
from domdf_python_tools.terminal_colours import Colour, Fore
9695
from domdf_python_tools.typing import HasHead, String
9796

9897
if typing.TYPE_CHECKING or domdf_python_tools.__docs: # pragma: no cover
9998
# 3rd party
10099
from pandas import DataFrame, Series # type: ignore
101100

101+
# this package
102+
from domdf_python_tools.terminal_colours import Colour, Fore
103+
102104
Series.__module__ = "pandas"
103105
DataFrame.__module__ = "pandas"
104106

@@ -626,8 +628,8 @@ def coloured_diff(
626628
tofiledate: str = '',
627629
n: int = 3,
628630
lineterm: str = '\n',
629-
removed_colour: Colour = Fore.RED,
630-
added_colour: Colour = Fore.GREEN,
631+
removed_colour: Optional["Colour"] = None,
632+
added_colour: Optional["Colour"] = None,
631633
) -> str:
632634
r"""
633635
Compare two sequences of lines; generate the delta as a unified diff.
@@ -682,6 +684,15 @@ def coloured_diff(
682684
# this package
683685
from domdf_python_tools.stringlist import StringList
684686

687+
with warnings.catch_warnings():
688+
warnings.simplefilter("ignore", DeprecationWarning)
689+
690+
# this package
691+
from domdf_python_tools.terminal_colours import Fore
692+
693+
removed_colour = removed_colour or Fore.RED
694+
added_colour = added_colour or Fore.GREEN
695+
685696
buf = StringList()
686697
diff = difflib.unified_diff(a, b, fromfile, tofile, fromfiledate, tofiledate, n, lineterm)
687698

0 commit comments

Comments
 (0)