From 8dc55f696cde7f5f39b641ddf5687aaa46b23686 Mon Sep 17 00:00:00 2001 From: coldsofttech Date: Sat, 13 Apr 2024 15:50:24 +0100 Subject: [PATCH] Updated Pipeline To Support Multi-OS & Added Support for PyPI Release --- .github/workflows/pipeline.yml | 13 ++++--------- src/__init__.py | 17 +---------------- tests/unit/test_aboutui.py | 6 ++---- tests/unit/test_downloadthread.py | 6 ++---- tests/unit/test_m3u8downloaderui.py | 6 ++---- tests/unit/test_stdoutredirector.py | 6 ++---- 6 files changed, 13 insertions(+), 41 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 95e5b2a..9cb274a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -65,21 +65,16 @@ jobs: pip install pytest pip install -r requirements.txt - - name: Install Dependencies (Ubuntu) + - name: Run Tests (Ubuntu) if: matrix.os == 'ubuntu-latest' run: | sudo apt-get install -y python3-tk sudo apt-get install -y xvfb - - - name: Start Virtual Display (Ubuntu) - if: matrix.os == 'ubuntu-latest' - run: | - # Xvfb :99 -screen 0 1024x768x16 & - # export DISPLAY=:99 ps aux | grep xvfb - xvfb-run --auto-servernum --server-args='-screen 0 1024x768x24' pytest tests + xvfb-run --auto-servernum --server-args='-screen 0 1024x768x24' pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes - - name: Run Tests + - name: Run Tests (Windows) + if: matrix.os == 'windows-latest' || matrix.os == 'macos-latest' run: | pytest tests -vv -rEPW -o pytest_collection_order=alphabetical --cache-clear --color=yes diff --git a/src/__init__.py b/src/__init__.py index 9d7738d..47826e4 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -474,23 +474,8 @@ def _open_license(self, event) -> None: webbrowser.open(self.license_link) -def get_root_window() -> tk.Tk: - # if platform.system().lower() == 'linux': - # setting = os.environ.__getitem__('DISPLAY') - # return tk.Tk(screenName=setting) - return tk.Tk() - - -def display_settings(): - if platform.system().lower() == 'linux': - if os.environ.get('DISPLAY', '') == '': - print('No display found. Using: :0') - os.environ['DISPLAY'] = ':0' - - def main(): - # root = tk.Tk() - root = get_root_window() + root = tk.Tk() M3U8DownloaderUI(root) root.mainloop() diff --git a/tests/unit/test_aboutui.py b/tests/unit/test_aboutui.py index 298dff9..a98b3bc 100644 --- a/tests/unit/test_aboutui.py +++ b/tests/unit/test_aboutui.py @@ -4,16 +4,14 @@ import pytest -from src import AboutUI, get_root_window +from src import AboutUI class TestAboutUI(unittest.TestCase): """Unit test cases for AboutUI""" def setUp(self): - # display_settings() - # self.root = tk.Tk() - self.root = get_root_window() + self.root = tk.Tk() def tearDown(self): try: diff --git a/tests/unit/test_downloadthread.py b/tests/unit/test_downloadthread.py index 38f502a..4d1a6d7 100644 --- a/tests/unit/test_downloadthread.py +++ b/tests/unit/test_downloadthread.py @@ -5,18 +5,16 @@ import pytest -from src import M3U8DownloaderUI, DownloadThread, get_root_window +from src import M3U8DownloaderUI, DownloadThread class TestDownloadThread(unittest.TestCase): """Unit test cases for DownloadThread class.""" def setUp(self): - # display_settings() + self.root = tk.Tk() self.input_url = 'https://raw.githubusercontent.com/coldsofttech/pym3u8downloader/main/tests/files/index.m3u8' self.output_file = 'video.mp4' - # self.root = tk.Tk() - self.root = get_root_window() self.source = M3U8DownloaderUI(self.root) self.config_file = 'config.json' diff --git a/tests/unit/test_m3u8downloaderui.py b/tests/unit/test_m3u8downloaderui.py index e07f9f5..1168778 100644 --- a/tests/unit/test_m3u8downloaderui.py +++ b/tests/unit/test_m3u8downloaderui.py @@ -4,16 +4,14 @@ import pytest -from src import M3U8DownloaderUI, get_root_window +from src import M3U8DownloaderUI class TestM3U8DownloaderUI(unittest.TestCase): """Unit test cases for M3U8DownloaderUI""" def setUp(self): - # display_settings() - # self.root = tk.Tk() - self.root = get_root_window() + self.root = tk.Tk() self.source = M3U8DownloaderUI(self.root) self.input_url = 'https://raw.githubusercontent.com/coldsofttech/pym3u8downloader/main/tests/files/index.m3u8' self.output_file = 'video.mp4' diff --git a/tests/unit/test_stdoutredirector.py b/tests/unit/test_stdoutredirector.py index dbd692a..0573985 100644 --- a/tests/unit/test_stdoutredirector.py +++ b/tests/unit/test_stdoutredirector.py @@ -3,16 +3,14 @@ import pytest -from src import StdoutRedirector, get_root_window +from src import StdoutRedirector class TestStdoutRedirector(unittest.TestCase): """Unit test cases for StdoutRedirector""" def setUp(self): - # display_settings() - # self.root = tk.Tk() - self.root = get_root_window() + self.root = tk.Tk() self.text_variable = tk.StringVar() self.stdout_redirector = StdoutRedirector(self.text_variable)