Skip to content

Commit

Permalink
Test (#215)
Browse files Browse the repository at this point in the history
* fix : tests updated

* fix : tests updated

* fix : minor edit in coverage call

* fix : .coveragerc updated

* fix : testcov and testcov2 mode removed

* fix : tests updated

* fix : autopep8

* doc : CHANGELOG updated

* fix : unused messages removed
  • Loading branch information
sepandhaghighi committed Nov 18, 2022
1 parent 3324e6f commit f575576
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
@@ -1,5 +1,8 @@
[run]
branch = True
omit =
art/__main__.py
art/__init__.py

[report]
exclude_lines =
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Expand Up @@ -24,8 +24,6 @@ jobs:
python setup.py install
python -m art test
python -m art test2
python -m art testcov
python -m art testcov2
- name: Install dev-requirements
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -53,7 +51,7 @@ jobs:
if: matrix.python-version == 3.8
- name: Codecov
run: |
python -m art testcov2
coverage run -m art test2
codecov
if: matrix.python-version == 3.8 && matrix.os == 'ubuntu-latest'
- name: Profile
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Test system modified
- `Python 3.11` added to `test.yml`
- `Conda-Forge` installing section added to `INSTALL.md`
### Removed
- `testcov` and `testcov2` modes
## [5.7] - 2022-07-06
### Added
- 5 new font
Expand Down
25 changes: 3 additions & 22 deletions art/__main__.py
@@ -1,16 +1,11 @@
# -*- coding: utf-8 -*-
"""Art main."""
from .art import *
from .art_param import FONT_MAP, ART_ENVIRONMENT_WARNING, FONT_ENVIRONMENT_WARNING, PACKAGE_LOAD_WARNING
from .art_param import FONT_MAP, ART_ENVIRONMENT_WARNING, FONT_ENVIRONMENT_WARNING
import sys
import doctest
import os
import zipfile
COVERAGE_INSTALL = True
try:
import coverage
except ImportError:
COVERAGE_INSTALL = False


def select_test(test_name="TEST"):
Expand All @@ -22,27 +17,17 @@ def select_test(test_name="TEST"):
:return: None
"""
error_flag_2 = 0
if test_name == "TESTCOV" or test_name == "TESTCOV2":
if COVERAGE_INSTALL:
cov = coverage.Coverage()
cov.start()
else:
print(PACKAGE_LOAD_WARNING)
error_flag_1 = doctest.testfile(
"test.py",
optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
| doctest.IGNORE_EXCEPTION_DETAIL,
verbose=False)[0]
if test_name == "TESTCOV2" or test_name == "TEST2":
if test_name == "TEST2":
error_flag_2 = doctest.testfile(
"test2.py",
optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL,
verbose=False)[0]
error_flag = error_flag_1 + error_flag_2
if (test_name == "TESTCOV" or test_name == "TESTCOV2") and COVERAGE_INSTALL:
cov.stop()
cov.report()
cov.save()
if error_flag == 0:
print("\n" + test_name + " Passed")
sys.exit(error_flag)
Expand All @@ -54,14 +39,10 @@ def select_test(test_name="TEST"):
if __name__ == "__main__":
args = sys.argv
if len(args) > 1:
if args[1].upper() == "TESTCOV":
select_test("TESTCOV")
elif args[1].upper() == "TEST":
if args[1].upper() == "TEST":
select_test("TEST")
elif args[1].upper() == "TEST2":
select_test("TEST2")
elif args[1].upper() == "TESTCOV2":
select_test("TESTCOV2")
elif args[1].upper() in ["LIST", "ARTS"]:
art_list()
elif args[1].upper() == "FONTS":
Expand Down
44 changes: 44 additions & 0 deletions art/test.py
Expand Up @@ -19,6 +19,46 @@
| '--------------' |
'----------------'
<BLANKLINE>
>>> tprint("\t\t2","block",sep=2)
<BLANKLINE>
.----------------.
| .--------------. |
| | _____ | |
| | / ___ `. | |
| | |_/___) | | |
| | .'____.' | |
| | / /____ | |
| | |_______| | |
| | | |
| '--------------' |
'----------------'
<BLANKLINE>
>>> tprint("\t\t2","block",sep="\n\n")
<BLANKLINE>
<BLANKLINE>
.----------------.
<BLANKLINE>
| .--------------. |
<BLANKLINE>
| | _____ | |
<BLANKLINE>
| | / ___ `. | |
<BLANKLINE>
| | |_/___) | | |
<BLANKLINE>
| | .'____.' | |
<BLANKLINE>
| | / /____ | |
<BLANKLINE>
| | |_______| | |
<BLANKLINE>
| | | |
<BLANKLINE>
| '--------------' |
<BLANKLINE>
'----------------'
<BLANKLINE>
<BLANKLINE>
>>> tprint(" ","block")
<BLANKLINE>
>>> tprint("123","alpha")
Expand Down Expand Up @@ -4600,6 +4640,10 @@
Traceback (most recent call last):
...
art.art.artError: The 'sep' type must be str.
>>> set_default(decoration=2)
Traceback (most recent call last):
...
art.art.artError: The 'decoration' type must be str.
>>> random.seed(200)
>>> Art = text2art("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~0123456789","rnd-small")
>>> random.seed(800)
Expand Down

0 comments on commit f575576

Please sign in to comment.