Skip to content

Commit b1d2055

Browse files
committed
Removed test for extra.force_sudo_password_promt()
It removes user's sudo timestamp which may be inconvenient. Removed meaningless quantifier "{1}" from gnu_coreutils.cd(). Formatted comments in test files to impove consistency and readability.
1 parent f8b29cc commit b1d2055

File tree

8 files changed

+26
-23
lines changed

8 files changed

+26
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ python3 -m pip install niceshell
1616

1717
```bash
1818
cd /tmp/
19-
version=1.0.1 # Choose desired version
19+
version=1.0.2 # Choose desired version
2020
wget -c "https://github.com/Andrew15-5/niceshell/releases/download/v${version}/niceshell-${version}-py3-none-any.whl"
2121
python3 -m pip -U --user install niceshell-${version}-py3-none-any.whl
2222
```

niceshell/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"normalize_short_and_long_args", "quotes_wrapper", "rm", "shell",
2121
"Shell", "ShortArgsOption", "UID", "USER"]
2222
__author__ = "Andrew Voynov"
23-
__version__ = "1.0.1"
23+
__version__ = "1.0.2"
2424

2525
GID = Shell("id -g").output()[:-1]
2626
GROUP = Shell("id -gn").output()[:-1]

niceshell/extra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def force_sudo_password_promt():
1212
def get_root_privileges():
1313
"""
1414
Shows sudo password prompt. Returns True if correct password has been
15-
entered, otherwise returns False (e.g. Ctrl+C was pressed).
15+
entered, otherwise returns False (e.g., Ctrl+C was pressed).
1616
"""
1717
return not shell("sudo true").exit_code()
1818

niceshell/gnu_coreutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def cd(path: str = '',
3535
if path:
3636
path = expose_tilde(quotes_wrapper(path))
3737
path = re.sub(r'(?<=[^\\])\*', '"*"', path) # Expose wildcard (*)
38-
path = re.sub(r'\\{1}\*', '*', path) # Preserve '*'
38+
path = re.sub(r'\\\*', '*', path) # Preserve '*'
3939
args = normalize_short_and_long_args(
4040
short_args, [], ShortArgsOption.APART)
4141
command = f"cd {args} -- {path}".strip()

niceshell/tests/test_core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_expose_tilde(self):
1313
quotes_wrapper = core.quotes_wrapper
1414

1515
# Errors
16-
# quoted_path must be str
16+
# quoted_path must be str.
1717
with pytest.raises(TypeError):
1818
expose_tilde(1)
1919
with pytest.raises(TypeError):
@@ -44,13 +44,13 @@ def test_normalize_short_and_long_args(self):
4444
with pytest.raises(TypeError):
4545
normalize('', [1])
4646

47-
# No spaces are allowed in short args which are TOGETHER
47+
# No spaces are allowed in short args which are TOGETHER.
4848
with pytest.raises(ValueError):
4949
normalize(' ')
5050
with pytest.raises(ValueError):
5151
normalize("-a -b")
5252

53-
# (Iterable[str]) Short args which are TOGETHER must be 1 char. long
53+
# (Iterable[str]) Short args which are TOGETHER must be 1 char. long.
5454
with pytest.raises(ValueError):
5555
normalize(["ab"], [])
5656
with pytest.raises(ValueError):
@@ -60,6 +60,7 @@ def test_normalize_short_and_long_args(self):
6060
with pytest.raises(ValueError):
6161
normalize([], [], True)
6262

63+
# Asserts
6364
# No args
6465
assert normalize() == ''
6566

@@ -157,7 +158,7 @@ def test_quotes_wrapper(self):
157158
with pytest.raises(TypeError):
158159
wrapper([1])
159160

160-
# Quotes
161+
# Asserts
161162
assert wrapper('') == '""'
162163
assert wrapper(' ') == '" "'
163164
assert wrapper(set(' ')) == '" "'

niceshell/tests/test_extra.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99

1010
class TestExtra:
11-
def test_force_sudo_password_promt(self):
12-
assert extra.force_sudo_password_promt() == None
13-
1411
def test_has_root_privileges(self):
1512
assert type(extra.has_root_privileges()) == bool
1613

niceshell/tests/test_gnu_coreutils.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def test_cp(self):
5757
with pytest.raises(TypeError):
5858
cp('', 1)
5959

60-
# Asserts batch=False
60+
# Asserts
61+
# batch=False
6162
def cp(source_path: Union[str, Iterable[str]],
6263
destination_path: str,
6364
sudo=False,
@@ -89,7 +90,7 @@ def cp(source_path: Union[str, Iterable[str]],
8990
short_args=['r', 'f', 'b', "S .bak"], long_args=["verbose"]
9091
) == 'sudo cp -r -f -b -S .bak --verbose -- "tmp/dir1" "dir2" ~/"d i r 3/src/" ~'
9192

92-
# Asserts batch=True
93+
# batch=True
9394
def cp(source_path: Union[str, Iterable[str]],
9495
destination_path: str,
9596
sudo=False,
@@ -141,7 +142,8 @@ def test_ln(self):
141142
with pytest.raises(TypeError):
142143
ln('', 1)
143144

144-
# Asserts batch=False
145+
# Asserts
146+
# batch=False
145147
def ln(source_path: Union[str, Iterable[str]],
146148
destination_path: str,
147149
sudo=False,
@@ -173,7 +175,7 @@ def ln(source_path: Union[str, Iterable[str]],
173175
short_args=['r', 's', 'f', "S .bak"], long_args=["verbose"]
174176
) == 'sudo ln -r -s -f -S .bak --verbose -- "tmp/dir1" "dir2" ~/"d i r 3/src/" ~'
175177

176-
# Asserts batch=True
178+
# batch=True
177179
def ln(source_path: Union[str, Iterable[str]],
178180
destination_path: str,
179181
sudo=False,
@@ -219,7 +221,8 @@ def test_ls(self):
219221
with pytest.raises(TypeError):
220222
ls([1], test=True)
221223

222-
# Asserts batch=False
224+
# Asserts
225+
# batch=False
223226
def ls(path: Union[str, Iterable[str]] = '',
224227
sudo=False,
225228
short_args: Union[str, Iterable[str]] = [],
@@ -251,7 +254,7 @@ def ls(path: Union[str, Iterable[str]] = '',
251254
short_args=['l', 'd', "-I PATTERN"], long_args=["all"]
252255
) == 'sudo ls -l -d -I PATTERN --all -- ~/"here/*" ~/"there/*"'
253256

254-
# Asserts batch=True
257+
# batch=True
255258
def ls(path: Union[str, Iterable[str]] = '',
256259
sudo=False,
257260
short_args: Union[str, Iterable[str]] = [],
@@ -305,7 +308,8 @@ def test_mv(self):
305308
with pytest.raises(TypeError):
306309
mv('', 1)
307310

308-
# Asserts batch=False
311+
# Asserts
312+
# batch=False
309313
def mv(source_path: Union[str, Iterable[str]],
310314
destination_path: str,
311315
sudo=False,
@@ -336,7 +340,7 @@ def mv(source_path: Union[str, Iterable[str]],
336340
short_args=['f', 'b', "S .bak"], long_args=["verbose"]
337341
) == 'sudo mv -f -b -S .bak --verbose -- "tmp/dir1" "dir2" ~/"d i r 3/src/" ~'
338342

339-
# Asserts batch=True
343+
# batch=True
340344
def mv(source_path: Union[str, Iterable[str]],
341345
destination_path: str,
342346
sudo=False,
@@ -384,7 +388,8 @@ def test_rm(self):
384388
with pytest.raises(TypeError):
385389
rm([1])
386390

387-
# Asserts batch=False
391+
# Asserts
392+
# batch=False
388393
def rm(path: Union[str, Iterable[str]],
389394
sudo=False,
390395
short_args: Union[str, Iterable[str]] = [],
@@ -413,7 +418,7 @@ def rm(path: Union[str, Iterable[str]],
413418
short_args=['r', 'f', "I"], long_args=["verbose"]
414419
) == 'sudo rm -r -f -I --verbose -- "tmp/dir1" "dir2" ~/"d i r 3/src/"'
415420

416-
# Asserts batch=True
421+
# batch=True
417422
def rm(path: Union[str, Iterable[str]],
418423
sudo=False,
419424
short_args: Union[str, Iterable[str]] = [],

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
setuptools.setup(
77
name="niceshell",
8-
version="1.0.1",
8+
version="1.0.2",
99
author="Andrew Voynov",
1010
author_email="[email protected]",
1111
description="Integration of shell and basic GNU core unilities for better coding.",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
1414
license="MIT",
1515
url="https://github.com/Andrew15-5/niceshell",
16-
download_url="https://github.com/Andrew15-5/niceshell/releases/download/v1.0.1/niceshell-1.0.1-py3-none-any.whl",
16+
download_url="https://github.com/Andrew15-5/niceshell/releases/download/v1.0.2/niceshell-1.0.2-py3-none-any.whl",
1717
packages=["niceshell", "niceshell/tests"],
1818
package_data={
1919
"niceshell": ['*']

0 commit comments

Comments
 (0)