Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run test suite
on:
pull_request:
workflow_dispatch:
push:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- run: pip install -r requirements.txt
- run: python -m unittest discover -s tests
25 changes: 25 additions & 0 deletions tests/support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
import contextlib

# -------------------------------- Imports ----------------------------------- #


# Support functions borrowed from CPython's test.support
@contextlib.contextmanager
def import_scripts(dir='..'):
with DirsOnSysPath(dir) as cm:
yield cm


class DirsOnSysPath(object):
def __init__(self, *paths):
self.original_value = sys.path[:]
self.original_object = sys.path
sys.path.extend(paths)

def __enter__(self):
return self

def __exit__(self, *ignore_exc):
sys.path = self.original_object
sys.path[:] = self.original_value
27 changes: 27 additions & 0 deletions tests/test_build_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import unittest
import support

from urllib3 import PoolManager

with support.import_scripts():
import build_status


class testBuildStatus(unittest.TestCase):
def test_get_languages(self):
result = {
language: translated_name
for language, translated_name in build_status.get_languages(PoolManager())
}

self.assertIn('en', result)
self.assertIn('pl', result)
self.assertIn('zh-cn', result)

self.assertEqual(result.get('en'), None)
self.assertEqual(result.get('pl'), 'polski')
self.assertEqual(result.get('zh-cn'), '简体中文')


if __name__ == '__main__':
unittest.main()
Loading