Skip to content

Commit

Permalink
Fixed paths in per-commit config (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
shpaker authored Aug 22, 2021
1 parent 0c8f08f commit 5070113
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ repos:
name: isort
entry: isort
language: system
files: ^(winregistry|test)/.+\.py$
files: ^(winregistry|tests)/.+\.py$
-
id: black
name: black
entry: black
language: system
files: ^(winregistry|test)/.+\.py$
files: ^(winregistry|tests)/.+\.py$
-
id: flake8
name: flake8
entry: flake8
language: system
files: ^(winregistry|test)/.+\.py$
files: ^(winregistry|tests)/.+\.py$
-
id: pylint
name: pylint
entry: pylint
language: system
files: ^(winregistry|test)/.+\.py$
files: ^(winregistry|tests)/.+\.py$
-
id: mypy
name: mypy
entry: mypy
language: system
files: ^(winregistry|test)/.+\.py$
files: ^(winregistry|tests)/.+\.py$
-
repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v3.4.0"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "winregistry"
version = "1.1.0"
version = "1.1.1"
description = "Library aimed at working with Windows registry"
authors = ["Aleksandr Shpak <[email protected]>"]
readme = "readme.md"
Expand Down Expand Up @@ -58,7 +58,7 @@ force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 120
src_paths = ["winregistry", "test"]
src_paths = ["winregistry", "tests"]
skip = [".mypy_cache", ".pytest_cache", "venv"]

[tool.pylint.messages_control]
Expand Down
23 changes: 10 additions & 13 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
from winreg import KEY_READ, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
from winreg import HKEY_CURRENT_USER, KEY_READ

from winregistry import WinRegistry
from winregistry.utils import (
expand_short_root,
get_access_key,
parse_path,
)
from winregistry.utils import expand_short_root, get_access_key, parse_path

TEST_REG_PATH = r"HKCU\SOFTWARE\_REMOVE_ME_"


def test_expand_short_root() -> None:
root = expand_short_root("HKU")
assert r"HKEY_USERS" == root, root
assert root == "HKEY_USERS", root


def test_expand_long_root() -> None:
root = expand_short_root("SOME_LONG_STRING")
assert "SOME_LONG_STRING" == root, root
assert root == "SOME_LONG_STRING", root


def test_get_access_key() -> None:
Expand All @@ -33,6 +29,7 @@ def test_parse_path() -> None:

def test_get_key_handle() -> None:
with WinRegistry() as reg:
# pylint: disable=protected-access
handler = reg._get_handler(
r"HKCU\SOFTWARE",
access=KEY_READ,
Expand Down Expand Up @@ -98,14 +95,14 @@ def test_delete_key() -> None:
reg_key = r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test"
with WinRegistry() as client:
try:
data = client.read_key(r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test")
client.read_key(r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test")
raise AssertionError
except FileNotFoundError:
pass
client.create_key(reg_key)
client.delete_key(r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test")
try:
data = client.read_key(r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test")
client.read_key(r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test")
raise AssertionError
except FileNotFoundError:
pass
Expand All @@ -115,21 +112,21 @@ def test_delete_key_tree() -> None:
reg_key = r"HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\test"
with WinRegistry() as client:
try:
data = client.read_key(reg_key)
client.read_key(reg_key)
raise AssertionError
except FileNotFoundError:
pass
client.create_key(reg_key + "\\test1\\test3")
client.write_entry(reg_key + "\\test1", "remove_me", "test")
client.delete_key_tree(reg_key)
try:
data = client.read_key(reg_key)
client.read_key(reg_key)
raise AssertionError
except FileNotFoundError:
pass


if __name__ == '__main__':
if __name__ == "__main__":
for key, value in list(globals().items()):
if callable(value) and key.startswith("test_"):
print("Testing {0}".format(key))
Expand Down

0 comments on commit 5070113

Please sign in to comment.