Yurii Paniv commited on
Commit
55d834b
·
1 Parent(s): 8d24ba9

Improve test formatting

Browse files
Files changed (3) hide show
  1. pytest.ini +1 -1
  2. requirements-test.txt +2 -1
  3. tests/test_converter.py +12 -2
pytest.ini CHANGED
@@ -1,3 +1,3 @@
1
  # pytest.ini
2
  [pytest]
3
- addopts = -vv --cov --cov-report html --cov-branch
 
1
  # pytest.ini
2
  [pytest]
3
+ addopts = --cov --cov-report html --cov-branch
requirements-test.txt CHANGED
@@ -1,2 +1,3 @@
1
  pytest==7.1.3
2
- pytest-cov==4.0.0
 
 
1
  pytest==7.1.3
2
+ pytest-cov==4.0.0
3
+ tabulate==0.8.10
tests/test_converter.py CHANGED
@@ -1,4 +1,5 @@
1
  import converter
 
2
 
3
 
4
  def test_cyrillic_converter():
@@ -9,9 +10,18 @@ def test_cyrillic_converter():
9
 
10
  def test_latin_converter():
11
  cases = _read_test_cases()
12
- print(cases)
13
  for case in cases:
14
- assert converter.to_latin(case[1]).lower() == case[0].lower()
 
 
 
 
 
 
 
 
 
15
 
16
 
17
  def test_letter_coverage():
 
1
  import converter
2
+ from tabulate import tabulate
3
 
4
 
5
  def test_cyrillic_converter():
 
10
 
11
  def test_latin_converter():
12
  cases = _read_test_cases()
13
+ failed = []
14
  for case in cases:
15
+ if converter.to_latin(case[1]).lower() != case[0].lower():
16
+ failed.append(
17
+ (case[1].lower(), converter.to_latin(case[1]).lower(), case[0].lower())
18
+ )
19
+ if len(failed) > 0:
20
+ failed_rows = "\n".join([str(item) for item in failed])
21
+ raise Exception(
22
+ f"Failed {len(failed)}/{len(cases)} ({round((len(failed)/len(cases))*100,2)}%) cases.\n"
23
+ + tabulate(failed, headers=["Original", "Converted", "Ground truth"])
24
+ )
25
 
26
 
27
  def test_letter_coverage():