File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Run test suite
2+ on :
3+ pull_request :
4+ workflow_dispatch :
5+ push :
6+
7+ jobs :
8+ test :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - uses : actions/checkout@v4
13+ with :
14+ persist-credentials : false
15+ - uses : actions/setup-python@v5
16+ with :
17+ python-version : " 3.x"
18+ - run : pip install -r requirements.txt
19+ - run : python -m unittest discover -s tests
Original file line number Diff line number Diff line change 1+ import sys
2+ import contextlib
3+
4+ # -------------------------------- Imports ----------------------------------- #
5+
6+
7+ # Support functions borrowed from CPython's test.support
8+ @contextlib .contextmanager
9+ def import_scripts (dir = '..' ):
10+ with DirsOnSysPath (dir ) as cm :
11+ yield cm
12+
13+
14+ class DirsOnSysPath (object ):
15+ def __init__ (self , * paths ):
16+ self .original_value = sys .path [:]
17+ self .original_object = sys .path
18+ sys .path .extend (paths )
19+
20+ def __enter__ (self ):
21+ return self
22+
23+ def __exit__ (self , * ignore_exc ):
24+ sys .path = self .original_object
25+ sys .path [:] = self .original_value
Original file line number Diff line number Diff line change 1+ import unittest
2+ import support
3+
4+ from urllib3 import PoolManager
5+
6+ with support .import_scripts ():
7+ import build_status
8+
9+
10+ class testBuildStatus (unittest .TestCase ):
11+ def test_get_languages (self ):
12+ result = {
13+ language : translated_name
14+ for language , translated_name in build_status .get_languages (PoolManager ())
15+ }
16+
17+ self .assertIn ('en' , result )
18+ self .assertIn ('pl' , result )
19+ self .assertIn ('zh-cn' , result )
20+
21+ self .assertEqual (result .get ('en' ), None )
22+ self .assertEqual (result .get ('pl' ), 'polski' )
23+ self .assertEqual (result .get ('zh-cn' ), '简体中文' )
24+
25+
26+ if __name__ == '__main__' :
27+ unittest .main ()
You can’t perform that action at this time.
0 commit comments