wizlib 0.9.1__tar.gz → 0.9.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wizlib might be problematic. Click here for more details.

wizlib-0.9.3/.version ADDED
@@ -0,0 +1 @@
1
+ 0.9.3
@@ -1,11 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizlib
3
- Version: 0.9.1
3
+ Version: 0.9.3
4
4
  Summary: A collection of Python modules that are useful across multiple projects
5
5
  Author-email: Francis Potter <wizlib@steampunkwizard.ca>
6
6
  License: MIT
7
7
  Requires-Python: >=3.8
8
8
  Description-Content-Type: text/markdown
9
+ Requires-Dist: gnureadline; platform_system == "Darwin"
10
+ Requires-Dist: pyreadline3; platform_system == "Windows"
11
+ Requires-Dist: PyYAML>=6.0.1
9
12
 
10
13
  # WizLib
11
14
 
@@ -1,4 +1,7 @@
1
1
  from unittest import TestCase
2
+ from unittest.mock import patch
3
+ from io import StringIO
4
+ import os
2
5
 
3
6
  from wizlib.command_handler import CommandHandler
4
7
  from .data_command import TestCommand
@@ -14,11 +17,13 @@ class TestCommandSync(TestCase):
14
17
  r, s = CommandHandler(TestCommand).handle()
15
18
  self.assertEqual(r, 'Play!')
16
19
 
20
+ @patch('sys.stdout', StringIO())
17
21
  def test_wrong_command(self):
18
22
  h = CommandHandler(TestCommand)
19
23
  c = h.get_command(['eat'])
20
24
  self.assertIsNone(c)
21
25
 
26
+ @patch('sys.stdout', StringIO())
22
27
  def test_handle_wrong_command(self):
23
28
  h = CommandHandler(TestCommand)
24
29
  r, s = h.handle(['eat'])
@@ -33,3 +38,20 @@ class TestCommandSync(TestCase):
33
38
  h = CommandHandler(TestCommand)
34
39
  c = h.get_command(['--xx', 'y', 'play'])
35
40
  self.assertEqual(c.xx, 'y')
41
+
42
+ def test_error(self):
43
+ with patch('sys.stdout', o := StringIO()):
44
+ with patch('sys.argv', ['', 'error']):
45
+ CommandHandler.shell(TestCommand)
46
+ o.seek(0)
47
+ r = o.read()
48
+ self.assertIn('division by zero', r)
49
+ self.assertEqual(len(r.splitlines()), 3)
50
+
51
+ @patch('sys.stdout', StringIO())
52
+ def test_error_debug(self):
53
+ os.environ['DEBUG'] = '1'
54
+ with self.assertRaises(ZeroDivisionError):
55
+ with patch('sys.argv', ['', 'error']):
56
+ CommandHandler.shell(TestCommand)
57
+ del os.environ['DEBUG']
@@ -1,6 +1,7 @@
1
1
  import sys
2
2
  from argparse import ArgumentError, ArgumentParser
3
3
  from dataclasses import dataclass
4
+ import os
4
5
 
5
6
  from wizlib.class_family import ClassFamily
6
7
  from wizlib.super_wrapper import SuperWrapper
@@ -60,7 +61,10 @@ class CommandHandler:
60
61
  if status:
61
62
  print(status)
62
63
  except Exception as error:
63
- print(f"\n{RED}{type(error).__name__}: {error}{RESET}\n")
64
+ if os.getenv('DEBUG'):
65
+ raise error
66
+ else:
67
+ print(f"\n{RED}{type(error).__name__}: {error}{RESET}\n")
64
68
 
65
69
 
66
70
  @dataclass
@@ -2,6 +2,7 @@ from argparse import Namespace
2
2
  from pathlib import Path
3
3
  import os
4
4
  from dataclasses import dataclass
5
+ from unittest.mock import patch
5
6
 
6
7
  from yaml import load
7
8
  from yaml import Loader
@@ -67,3 +68,16 @@ class ConfigMachine:
67
68
  """Allows a Command class to also inherit from ConfigMachine. List
68
69
  ConfigMachine first."""
69
70
  parser.add_argument('--config', action='store')
71
+
72
+
73
+ def nohome_test(): # pragma: nocover
74
+ """Fake out a ConfigMachine so that it thinks test/files is the home
75
+ directory. This way it's not tempted to pull real configuration."""
76
+ return patch('pathlib.Path.home', lambda: Path('test/files'))
77
+
78
+
79
+ def patchconfig_test(**kwargs): # pragma: nocover
80
+ """Hand testable config data to a test method. First pass: always return
81
+ None."""
82
+ methodpath = 'wizlib.config_machine.ConfigMachine.config_get'
83
+ return patch(methodpath, lambda s, t: True)
@@ -1,11 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizlib
3
- Version: 0.9.1
3
+ Version: 0.9.3
4
4
  Summary: A collection of Python modules that are useful across multiple projects
5
5
  Author-email: Francis Potter <wizlib@steampunkwizard.ca>
6
6
  License: MIT
7
7
  Requires-Python: >=3.8
8
8
  Description-Content-Type: text/markdown
9
+ Requires-Dist: gnureadline; platform_system == "Darwin"
10
+ Requires-Dist: pyreadline3; platform_system == "Windows"
11
+ Requires-Dist: PyYAML>=6.0.1
9
12
 
10
13
  # WizLib
11
14
 
wizlib-0.9.1/.version DELETED
@@ -1 +0,0 @@
1
- 0.9.1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes