Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
reloadsweety committed Feb 13, 2025
1 parent c4de86d commit e49de8b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Binary file modified dist/ntk.exe
Binary file not shown.
9 changes: 7 additions & 2 deletions ntk/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
# This script is used to create a command alias (`ntk`) for running a Python module (`ntk`) more easily.

# To generate an executable using PyInstaller, use the following command:
# python -m PyInstaller --onefile --console .\ntk\installer.py -n n
# python -m PyInstaller --onefile --console .\ntk\installer.py -n ntk

if __name__ == "__main__":

def auto_install_and_generate_ntk_command():
subprocess.run(['python', '-m', 'pip', 'install', 'next-theme-kit'])

# Set up a command alias: 'ntk' will execute 'python -m ntk' with any passed arguments
os.system("doskey ntk=python -m ntk $*")

# Open a new command prompt window and keep it open
os.system("cmd /k")


if __name__ == "__main__":
auto_install_and_generate_ntk_command()

Check warning on line 24 in ntk/installer.py

View check run for this annotation

Codecov / codecov/patch

ntk/installer.py#L24

Added line #L24 was not covered by tests
16 changes: 16 additions & 0 deletions tests/test_installer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from unittest.case import TestCase
from unittest.mock import patch

from ntk.installer import auto_install_and_generate_ntk_command


class TestInstaller(TestCase):
def test_auto_install_and_generate_ntk_command_should_call_subprocess_and_os_correctly(self):
with patch("subprocess.run") as mock_subprocess, patch("os.system") as mock_os:
auto_install_and_generate_ntk_command()

mock_subprocess.assert_called_with(['python', '-m', 'pip', 'install', 'next-theme-kit'])

mock_os.assert_any_call("doskey ntk=python -m ntk $*")

mock_os.assert_any_call("cmd /k")

0 comments on commit e49de8b

Please sign in to comment.