Skip to content

Commit

Permalink
Adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apetenchea committed Sep 10, 2023
1 parent b76cf9a commit deee1d6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<li><a href="#contributing">Contributing</a></li>
<ul>
<li><a href="#building">Building</a></li>
<li><a href="#testing">Testing</a></li>
<li><a href="#formatting">Formatting</a></li>
</ul>
<li><a href="#disclaimer">Disclaimer</a></li>
Expand Down Expand Up @@ -138,6 +139,11 @@ Contributions are always welcome! Feel free to open an issue or submit a pull re
driver to be loaded with a real signature, and is going to be automatically signed with a test certificate during the
build process. **In case you're using BitLocker, be sure to have your recovery key at hand before rebooting.**
### Testing
```shell
py.test test.py
```

### Formatting
- C: `clang-format -i -style=Microsoft *.h *.c`
- Python: `black *.py`
Expand Down
48 changes: 48 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import hashlib
import ksh
import os
import psutil
import subprocess

MD5SUM = "d8a9e839260c00e65cc91be886638871"


def test_driver_test():
ksh.test()


def test_driver_cp():
from_file = "LICENSE"
to_file = "hund"
ksh.cp(
os.path.abspath(".") + "\\" + from_file, os.path.abspath(".") + "\\" + to_file
)
assert os.path.exists(to_file)
assert hashlib.md5(open(to_file, "rb").read()).hexdigest() == MD5SUM


def test_driver_mv():
from_file = "hund"
to_file = "katze"
ksh.mv(
os.path.abspath(".") + "\\" + from_file, os.path.abspath(".") + "\\" + to_file
)
assert os.path.exists(to_file)
assert not os.path.exists(from_file)
assert hashlib.md5(open(to_file, "rb").read()).hexdigest() == MD5SUM


def test_driver_rm():
path = os.path.abspath(".") + "\\" + "katze"
ksh.rm(path)
assert not os.path.exists(path)


def test_driver_pkill():
notepad = "notepad.exe"
process = subprocess.Popen([notepad])
pid = process.pid
ksh.pkill(pid)
for proc in psutil.process_iter():
if proc.name() == notepad:
assert pid != proc.pid

0 comments on commit deee1d6

Please sign in to comment.