Skip to content

Commit

Permalink
Remove all unittest imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Sep 5, 2023
1 parent f796f09 commit b4b2fe6
Show file tree
Hide file tree
Showing 19 changed files with 0 additions and 99 deletions.
6 changes: 0 additions & 6 deletions tests/test_bisect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.bisect import find_ge, find_gt, find_le, find_lt, index


Expand All @@ -12,7 +10,3 @@ def test_funcs(self):
assert find_le(l, 1) == 1
assert find_ge(l, 2) == 2
# assert index([0, 1, 1.5, 2], 1.501, atol=0.1) == 4


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_design_patterns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.design_patterns import cached_class, singleton


Expand Down Expand Up @@ -43,7 +41,3 @@ def test_cached_class(self):
# a = A(2)
# o = pickle.dumps(a)
# assert a == pickle.loads(o)


if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/test_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,3 @@ def test_get_ncpus(self):

def test_install_except_hook(self):
install_excepthook()


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_fnmatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.fnmatch import WildCard


Expand All @@ -8,7 +6,3 @@ def test_match(self):
wc = WildCard("*.pdf")
assert wc.match("A.pdf")
assert not wc.match("A.pdg")


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_fractions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

import pytest

from monty.fractions import gcd, gcd_float, lcm
Expand All @@ -15,7 +13,3 @@ def test_lcm(self):
def test_gcd_float(self):
vs = [6.2, 12.4, 15.5 + 5e-9]
assert gcd_float(vs, 1e-8) == pytest.approx(3.1)


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_inspect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.inspect import all_subclasses, caller_name, find_top_pyfile


Expand Down Expand Up @@ -27,7 +25,3 @@ def test_func(self):

def test_all_subclasses(self):
assert all_subclasses(LittleCatA) == [LittleCatB, LittleCatD]


if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,3 @@ def test_raise(self):

def teardown_method(self):
self.lock.release()


if __name__ == "__main__":
unittest.main()
5 changes: 0 additions & 5 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import json
import os
import pathlib
import unittest
from enum import Enum

import numpy as np
Expand Down Expand Up @@ -710,7 +709,3 @@ def test_dataclass(self):
str_ = json.dumps(ndc, cls=MontyEncoder)
ndc2 = json.loads(str_, cls=MontyDecoder)
assert isinstance(ndc2, NestedDataClass)


if __name__ == "__main__":
unittest.main()
5 changes: 0 additions & 5 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import unittest
from io import StringIO

from monty.logging import logged
Expand All @@ -15,7 +14,3 @@ def test_logged(self):
s = StringIO()
logging.basicConfig(level=logging.DEBUG, stream=s)
add(1, 2)


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_math.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.math import nCr, nPr


Expand All @@ -9,7 +7,3 @@ def test_nCr(self):

def test_deprecated_property(self):
assert nPr(4, 2) == 12


if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ def test_imap_tqdm(self):
assert len(results) == 10000
assert results[0] == 0
assert results[400] == 400


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import unittest

from monty.operator import operator_from_str


class TestOperator:
def test_something(self):
assert operator_from_str("==")(1, 1) and operator_from_str("+")(1, 1) == 2


if __name__ == "__main__":
unittest.main()
5 changes: 0 additions & 5 deletions tests/test_os.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import unittest

import pytest

Expand Down Expand Up @@ -46,7 +45,3 @@ def test_makedirs_p(self):

def teardown_method(self):
os.rmdir(self.test_dir_path)


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_pprint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.pprint import draw_tree, pprint_table


Expand Down Expand Up @@ -35,7 +33,3 @@ def __str__(self):
)

print(draw_tree(root))


if __name__ == "__main__":
unittest.main()
5 changes: 0 additions & 5 deletions tests/test_re.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import unittest

from monty.re import regrep

Expand Down Expand Up @@ -28,7 +27,3 @@ def test_regrep(self):
)
assert len(matches["1"]) == 1
assert len(matches["3"]) == 11


if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,3 @@ def test_mpk(self):
with open("test_file.json") as f:
reloaded = json.loads(f.read())
assert reloaded["test"] == 1


if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,3 @@ def test_remove_symlink_follow(self):
assert not os.path.isfile(tempf)
assert not os.path.isdir(tempdir)
assert not os.path.islink(templink)


if __name__ == "__main__":
unittest.main()
5 changes: 0 additions & 5 deletions tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import random
import sys
import unittest

from monty.string import remove_non_ascii, unicode2str

Expand All @@ -21,7 +20,3 @@ def test_unicode2str(self):
assert type(unicode2str("a")) == str
else:
assert type(unicode2str("a")) == str


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions tests/test_subprocess.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import unittest

from monty.subprocess import Command


Expand All @@ -16,7 +14,3 @@ def test_command(self):
sleep05.run(timeout=0.1)
assert sleep05.retcode != 0
assert sleep05.killed


if __name__ == "__main__":
unittest.main()

0 comments on commit b4b2fe6

Please sign in to comment.