tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
pythonPackages.pywbem: 0.10.0 -> 0.12.6
worldofpeace
7 years ago
db2cebbe
f211bad8
+41
-526
3 changed files
expand all
collapse all
unified
split
pkgs
development
python-modules
pywbem
default.nix
make_cimdatetime_timezone_aware.patch
top-level
python-packages.nix
+40
-33
pkgs/development/python-modules/pywbem/default.nix
···
1
1
-
{ stdenv, buildPythonPackage, fetchFromGitHub, libxml2
2
2
-
, m2crypto, ply, pyyaml, six
3
3
-
, httpretty, lxml, mock, pytest, requests
1
1
+
{ lib, buildPythonPackage, fetchPypi, libxml2
2
2
+
, m2crypto, ply, pyyaml, six, pbr, pythonOlder, isPy37, python
3
3
+
, httpretty, lxml, mock, pytest, requests, decorator, unittest2
4
4
}:
5
5
6
6
buildPythonPackage rec {
7
7
pname = "pywbem";
8
8
-
version = "0.10.0";
8
8
+
version = "0.12.6";
9
9
+
10
10
+
# Support added in master https://github.com/pywbem/pywbem/commit/b2f2f1a151a30355bbc6652dca69a7b30bfe941e awaiting release
11
11
+
disabled = isPy37;
9
12
10
10
-
src = fetchFromGitHub {
11
11
-
owner = "pywbem";
12
12
-
repo = "pywbem";
13
13
-
rev = "v${version}";
14
14
-
sha256 = "0jcwklip03xcni0dvsk9va8ilqz21g4fxwqd5kzvv91slaadfcym";
13
13
+
src = fetchPypi {
14
14
+
inherit pname version;
15
15
+
sha256 = "1dc6b745rrys600n05apdf6lb2vv5arlcwv7aiz9whgkbcd9qhki";
15
16
};
16
17
17
17
-
patches = [
18
18
-
# fix timezone handling so the tests pass again. Can go when 0.10.1 is released
19
19
-
# https://github.com/pywbem/pywbem/issues/755#issuecomment-327508681
20
20
-
./make_cimdatetime_timezone_aware.patch
18
18
+
propagatedBuildInputs = [
19
19
+
mock
20
20
+
pbr
21
21
+
ply
22
22
+
pyyaml
23
23
+
six
24
24
+
] ++ lib.optionals (pythonOlder "3.0") [ m2crypto ];
25
25
+
26
26
+
checkInputs = [
27
27
+
decorator
28
28
+
httpretty
29
29
+
libxml2
30
30
+
lxml
31
31
+
pytest
32
32
+
requests
33
33
+
unittest2
21
34
];
22
35
23
23
-
propagatedBuildInputs = [ m2crypto ply pyyaml six ];
36
36
+
postPatch = ''
37
37
+
# Uses deprecated library yamlordereddictloader
38
38
+
rm testsuite/test_client.py
24
39
25
25
-
checkInputs = [ httpretty lxml mock pytest requests ];
40
40
+
# Wants `wbemcli` in PATH
41
41
+
rm testsuite/test_wbemcli.py
42
42
+
43
43
+
# Disables tests that use testfixtures which is currently broken by nonbuilding zope_component
44
44
+
rm testsuite/{test_logging,test_recorder,test_wbemconnection_mock}.*
45
45
+
'';
26
46
27
27
-
# 1 test fails because it doesn't like running in our sandbox. Deleting the
28
28
-
# whole file is admittedly a little heavy-handed but at least the vast
29
29
-
# majority of tests are run.
30
47
checkPhase = ''
31
31
-
rm testsuite/testclient/networkerror.yaml
32
32
-
33
33
-
substituteInPlace makefile \
34
34
-
--replace "PYTHONPATH=." "" \
35
35
-
--replace '--cov $(package_name) --cov-config coveragerc' ""
36
36
-
37
37
-
for f in testsuite/test_cim_xml.py testsuite/validate.py ; do
38
38
-
substituteInPlace $f --replace "'xmllint" "'${stdenv.lib.getBin libxml2}/bin/xmllint"
39
39
-
done
40
40
-
41
41
-
make PATH=$PATH:${stdenv.lib.getBin libxml2}/bin test
48
48
+
pytest testsuite/
42
49
'';
43
50
44
44
-
meta = with stdenv.lib; {
45
45
-
description = "Support for the WBEM standard for systems management.";
46
46
-
homepage = http://pywbem.github.io/pywbem/;
47
47
-
license = licenses.gpl2;
51
51
+
meta = with lib; {
52
52
+
description = "Support for the WBEM standard for systems management";
53
53
+
homepage = https://pywbem.github.io;
54
54
+
license = licenses.lgpl21Plus;
48
55
maintainers = with maintainers; [ peterhoeg ];
49
56
};
50
57
}
-491
pkgs/development/python-modules/pywbem/make_cimdatetime_timezone_aware.patch
···
1
1
-
From bb7fa19d636d999bf844d80939e155b8f212ef3e Mon Sep 17 00:00:00 2001
2
2
-
From: Andreas Maier <maiera@de.ibm.com>
3
3
-
Date: Fri, 23 Jun 2017 19:13:51 +0200
4
4
-
Subject: [PATCH] Made CIMDateTime always timezone-aware, re-enabled
5
5
-
test_cim_types.py
6
6
-
7
7
-
Details:
8
8
-
- Ensured that 'CIMDateTime' objects for point in time values are
9
9
-
timezone-aware when supplied with a timezone-naive 'datetime'
10
10
-
object. This does not change the behavior, but increases code
11
11
-
clarity.
12
12
-
- Clarified that in the documentation of 'CIMDateTime'.
13
13
-
- Added testcases for CIMDateTime.
14
14
-
- Re-enabled the testing of test_cim_types.py. Since its change
15
15
-
to using pytest it was not run because the test methods were
16
16
-
all static methods which apparently does not work. Not sure
17
17
-
this ever worked.
18
18
-
19
19
-
Signed-off-by: Andreas Maier <maiera@de.ibm.com>
20
20
-
---
21
21
-
docs/changes.rst | 5 +
22
22
-
pywbem/cim_types.py | 22 +--
23
23
-
testsuite/test_cim_types.py | 369 +++++++++++++++++++++++---------------------
24
24
-
3 files changed, 207 insertions(+), 189 deletions(-)
25
25
-
26
26
-
diff --git a/docs/changes.rst b/docs/changes.rst
27
27
-
index 272ed30d..6fdfbcf4 100644
28
28
-
--- a/docs/changes.rst
29
29
-
+++ b/docs/changes.rst
30
30
-
@@ -72,6 +72,11 @@ Enhancements
31
31
-
32
32
-
* Added unit test for recorder. See issue #676
33
33
-
34
34
-
+* Ensured that `CIMDateTime` objects for point in time values are
35
35
-
+ timezone-aware when supplied with a timezone-naive `datetime` object.
36
36
-
+ This does not change the behavior, but increases code clarity.
37
37
-
+ Clarified that in the documentation of `CIMDateTime`. See issue #698.
38
38
-
+
39
39
-
Bug fixes
40
40
-
^^^^^^^^^
41
41
-
42
42
-
diff --git a/pywbem/cim_types.py b/pywbem/cim_types.py
43
43
-
index 6d1f140c..5ecc7707 100644
44
44
-
--- a/pywbem/cim_types.py
45
45
-
+++ b/pywbem/cim_types.py
46
46
-
@@ -74,6 +74,7 @@
47
47
-
import re
48
48
-
import warnings
49
49
-
import six
50
50
-
+import copy
51
51
-
52
52
-
from . import config
53
53
-
54
54
-
@@ -294,9 +295,11 @@ def __init__(self, dtarg):
55
55
-
* A :term:`string` object will be
56
56
-
interpreted as CIM datetime format (see :term:`DSP0004`) and
57
57
-
will result in a point in time or a time interval.
58
58
-
- * A :class:`py:datetime.datetime` object must be timezone-aware
59
59
-
- (see :class:`~pywbem.MinutesFromUTC`) and will result in a point
60
60
-
- in time.
61
61
-
+ * A :class:`py:datetime.datetime` object will result in a point
62
62
-
+ in time. If the :class:`py:datetime.datetime` object is
63
63
-
+ timezone-aware (see :class:`~pywbem.MinutesFromUTC`), the
64
64
-
+ specified timezone will be used. Otherwise, a default timezone
65
65
-
+ of UTC will be assumed.
66
66
-
* A :class:`py:datetime.timedelta` object will result in a time
67
67
-
interval.
68
68
-
* Another :class:`~pywbem.CIMDateTime` object will be copied.
69
69
-
@@ -342,14 +345,15 @@ def __init__(self, dtarg):
70
70
-
raise ValueError('dtarg argument "%s" has an invalid CIM '
71
71
-
'datetime format' % dtarg)
72
72
-
elif isinstance(dtarg, datetime):
73
73
-
- self.__datetime = dtarg
74
74
-
+ if dtarg.tzinfo is None:
75
75
-
+ self.__datetime = dtarg.replace(tzinfo=MinutesFromUTC(0))
76
76
-
+ else:
77
77
-
+ self.__datetime = copy.copy(dtarg)
78
78
-
elif isinstance(dtarg, timedelta):
79
79
-
- self.__timedelta = dtarg
80
80
-
+ self.__timedelta = copy.copy(dtarg)
81
81
-
elif isinstance(dtarg, CIMDateTime):
82
82
-
- # pylint: disable=protected-access
83
83
-
- self.__datetime = dtarg.__datetime
84
84
-
- # pylint: disable=protected-access
85
85
-
- self.__timedelta = dtarg.__timedelta
86
86
-
+ self.__datetime = copy.copy(dtarg.datetime)
87
87
-
+ self.__timedelta = copy.copy(dtarg.timedelta)
88
88
-
else:
89
89
-
raise TypeError('dtarg argument "%s" has an invalid type: %s '
90
90
-
'(expected datetime, timedelta, string, or '
91
91
-
diff --git a/testsuite/test_cim_types.py b/testsuite/test_cim_types.py
92
92
-
index 4ae354d3..b1f54d06 100755
93
93
-
--- a/testsuite/test_cim_types.py
94
94
-
+++ b/testsuite/test_cim_types.py
95
95
-
@@ -43,105 +43,99 @@ def integer_tuple(request):
96
96
-
return request.param
97
97
-
98
98
-
99
99
-
-class TestIntegers:
100
100
-
- """
101
101
-
- Test CIM integer data type classes.
102
102
-
- """
103
103
-
-
104
104
-
- @staticmethod
105
105
-
- def test_class_attrs_class(integer_tuple):
106
106
-
- """Test class attrs via class level"""
107
107
-
- obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
108
108
-
- assert obj_type.cimtype == exp_cimtype
109
109
-
- assert obj_type.minvalue == exp_minvalue
110
110
-
- assert obj_type.maxvalue == exp_maxvalue
111
111
-
-
112
112
-
- @staticmethod
113
113
-
- def test_class_attrs_inst(integer_tuple):
114
114
-
- """Test class attrs via instance level"""
115
115
-
- obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
116
116
-
- obj = obj_type(42)
117
117
-
- assert obj.cimtype == exp_cimtype
118
118
-
- assert obj.minvalue == exp_minvalue
119
119
-
- assert obj.maxvalue == exp_maxvalue
120
120
-
-
121
121
-
- @staticmethod
122
122
-
- def test_inheritance(integer_tuple):
123
123
-
- """Test inheritance"""
124
124
-
- obj_type = integer_tuple[0]
125
125
-
- obj = obj_type(42)
126
126
-
- assert isinstance(obj, obj_type)
127
127
-
- assert isinstance(obj, CIMType)
128
128
-
- assert isinstance(obj, CIMInt)
129
129
-
- assert not isinstance(obj, CIMFloat)
130
130
-
-
131
131
-
- @staticmethod
132
132
-
- def test_init_int(integer_tuple):
133
133
-
- """Test initialization from integer value"""
134
134
-
- obj_type = integer_tuple[0]
135
135
-
- obj = obj_type(42)
136
136
-
- assert obj == 42
137
137
-
-
138
138
-
- @staticmethod
139
139
-
- def test_init_str(integer_tuple):
140
140
-
- """Test initialization from string value"""
141
141
-
- obj_type = integer_tuple[0]
142
142
-
- obj = obj_type('42')
143
143
-
- assert obj == 42
144
144
-
-
145
145
-
- @staticmethod
146
146
-
- def test_init_str_base10(integer_tuple):
147
147
-
- """Test initialization from string value with base 10"""
148
148
-
- obj_type = integer_tuple[0]
149
149
-
- obj = obj_type('42', 10)
150
150
-
- assert obj == 42
151
151
-
-
152
152
-
- @staticmethod
153
153
-
- def test_init_str_base16(integer_tuple):
154
154
-
- """Test initialization from string value with base 16"""
155
155
-
- obj_type = integer_tuple[0]
156
156
-
- obj = obj_type('2A', 16)
157
157
-
- assert obj == 42
158
158
-
-
159
159
-
- @staticmethod
160
160
-
- def test_init_minimum(integer_tuple):
161
161
-
- """Test initialization from integer value at minimum"""
162
162
-
- obj_type = integer_tuple[0]
163
163
-
- exp_minvalue = integer_tuple[2]
164
164
-
- obj = obj_type(exp_minvalue)
165
165
-
- assert obj == exp_minvalue
166
166
-
-
167
167
-
- @staticmethod
168
168
-
- def test_init_maximum(integer_tuple):
169
169
-
- """Test initialization from integer value at maximum"""
170
170
-
- obj_type = integer_tuple[0]
171
171
-
- exp_maxvalue = integer_tuple[3]
172
172
-
- obj = obj_type(exp_maxvalue)
173
173
-
- assert obj == exp_maxvalue
174
174
-
-
175
175
-
- @staticmethod
176
176
-
- def test_init_too_low(integer_tuple):
177
177
-
- """Test initialization from integer value below minimum"""
178
178
-
- obj_type = integer_tuple[0]
179
179
-
- exp_minvalue = integer_tuple[2]
180
180
-
- try:
181
181
-
- obj_type(exp_minvalue - 1)
182
182
-
- except ValueError:
183
183
-
- pass
184
184
-
- else:
185
185
-
- raise AssertionError("ValueError was not raised.")
186
186
-
-
187
187
-
- @staticmethod
188
188
-
- def test_init_too_high(integer_tuple):
189
189
-
- """Test initialization from integer value above maximum"""
190
190
-
- obj_type = integer_tuple[0]
191
191
-
- exp_maxvalue = integer_tuple[3]
192
192
-
- try:
193
193
-
- obj_type(exp_maxvalue + 1)
194
194
-
- except ValueError:
195
195
-
- pass
196
196
-
- else:
197
197
-
- raise AssertionError("ValueError was not raised.")
198
198
-
+def test_integer_class_attrs_class(integer_tuple):
199
199
-
+ """Test class attrs via class level"""
200
200
-
+ obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
201
201
-
+ assert obj_type.cimtype == exp_cimtype
202
202
-
+ assert obj_type.minvalue == exp_minvalue
203
203
-
+ assert obj_type.maxvalue == exp_maxvalue
204
204
-
+
205
205
-
+
206
206
-
+def test_integer_class_attrs_inst(integer_tuple):
207
207
-
+ """Test class attrs via instance level"""
208
208
-
+ obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
209
209
-
+ obj = obj_type(42)
210
210
-
+ assert obj.cimtype == exp_cimtype
211
211
-
+ assert obj.minvalue == exp_minvalue
212
212
-
+ assert obj.maxvalue == exp_maxvalue
213
213
-
+
214
214
-
+
215
215
-
+def test_integer_inheritance(integer_tuple):
216
216
-
+ """Test inheritance"""
217
217
-
+ obj_type = integer_tuple[0]
218
218
-
+ obj = obj_type(42)
219
219
-
+ assert isinstance(obj, obj_type)
220
220
-
+ assert isinstance(obj, CIMType)
221
221
-
+ assert isinstance(obj, CIMInt)
222
222
-
+ assert not isinstance(obj, CIMFloat)
223
223
-
+
224
224
-
+
225
225
-
+def test_integer_init_int(integer_tuple):
226
226
-
+ """Test initialization from integer value"""
227
227
-
+ obj_type = integer_tuple[0]
228
228
-
+ obj = obj_type(42)
229
229
-
+ assert obj == 42
230
230
-
+
231
231
-
+
232
232
-
+def test_integer_init_str(integer_tuple):
233
233
-
+ """Test initialization from string value"""
234
234
-
+ obj_type = integer_tuple[0]
235
235
-
+ obj = obj_type('42')
236
236
-
+ assert obj == 42
237
237
-
+
238
238
-
+
239
239
-
+def test_integer_init_str_base10(integer_tuple):
240
240
-
+ """Test initialization from string value with base 10"""
241
241
-
+ obj_type = integer_tuple[0]
242
242
-
+ obj = obj_type('42', 10)
243
243
-
+ assert obj == 42
244
244
-
+
245
245
-
+
246
246
-
+def test_integer_init_str_base16(integer_tuple):
247
247
-
+ """Test initialization from string value with base 16"""
248
248
-
+ obj_type = integer_tuple[0]
249
249
-
+ obj = obj_type('2A', 16)
250
250
-
+ assert obj == 42
251
251
-
+
252
252
-
+
253
253
-
+def test_integer_init_minimum(integer_tuple):
254
254
-
+ """Test initialization from integer value at minimum"""
255
255
-
+ obj_type = integer_tuple[0]
256
256
-
+ exp_minvalue = integer_tuple[2]
257
257
-
+ obj = obj_type(exp_minvalue)
258
258
-
+ assert obj == exp_minvalue
259
259
-
+
260
260
-
+
261
261
-
+def test_integer_init_maximum(integer_tuple):
262
262
-
+ """Test initialization from integer value at maximum"""
263
263
-
+ obj_type = integer_tuple[0]
264
264
-
+ exp_maxvalue = integer_tuple[3]
265
265
-
+ obj = obj_type(exp_maxvalue)
266
266
-
+ assert obj == exp_maxvalue
267
267
-
+
268
268
-
+
269
269
-
+def test_integer_init_too_low(integer_tuple):
270
270
-
+ """Test initialization from integer value below minimum"""
271
271
-
+ obj_type = integer_tuple[0]
272
272
-
+ exp_minvalue = integer_tuple[2]
273
273
-
+ try:
274
274
-
+ obj_type(exp_minvalue - 1)
275
275
-
+ except ValueError:
276
276
-
+ pass
277
277
-
+ else:
278
278
-
+ raise AssertionError("ValueError was not raised.")
279
279
-
+
280
280
-
+
281
281
-
+def test_integer_init_too_high(integer_tuple):
282
282
-
+ """Test initialization from integer value above maximum"""
283
283
-
+ obj_type = integer_tuple[0]
284
284
-
+ exp_maxvalue = integer_tuple[3]
285
285
-
+ try:
286
286
-
+ obj_type(exp_maxvalue + 1)
287
287
-
+ except ValueError:
288
288
-
+ pass
289
289
-
+ else:
290
290
-
+ raise AssertionError("ValueError was not raised.")
291
291
-
292
292
-
293
293
-
#
294
294
-
@@ -164,47 +158,41 @@ def real_tuple(request):
295
295
-
return request.param
296
296
-
297
297
-
298
298
-
-class TestReals:
299
299
-
- """
300
300
-
- Test CIM real data type classes.
301
301
-
- """
302
302
-
-
303
303
-
- @staticmethod
304
304
-
- def test_class_attrs_class(real_tuple):
305
305
-
- """Test class attrs via class level"""
306
306
-
- obj_type, exp_cimtype = real_tuple
307
307
-
- assert obj_type.cimtype == exp_cimtype
308
308
-
-
309
309
-
- @staticmethod
310
310
-
- def test_class_attrs_inst(real_tuple):
311
311
-
- """Test class attrs via instance level"""
312
312
-
- obj_type, exp_cimtype = real_tuple
313
313
-
- obj = obj_type(42)
314
314
-
- assert obj.cimtype == exp_cimtype
315
315
-
-
316
316
-
- @staticmethod
317
317
-
- def test_inheritance(real_tuple):
318
318
-
- """Test inheritance"""
319
319
-
- obj_type = real_tuple[0]
320
320
-
- obj = obj_type(42)
321
321
-
- assert isinstance(obj, obj_type)
322
322
-
- assert isinstance(obj, CIMType)
323
323
-
- assert isinstance(obj, CIMFloat)
324
324
-
- assert not isinstance(obj, CIMInt)
325
325
-
-
326
326
-
- @staticmethod
327
327
-
- def test_init_float(real_tuple):
328
328
-
- """Test initialization from floating point value"""
329
329
-
- obj_type = real_tuple[0]
330
330
-
- obj = obj_type(42.0)
331
331
-
- assert obj == 42.0
332
332
-
-
333
333
-
- @staticmethod
334
334
-
- def test_init_str(real_tuple):
335
335
-
- """Test initialization from string value"""
336
336
-
- obj_type = real_tuple[0]
337
337
-
- obj = obj_type('42.0')
338
338
-
- assert obj == 42.0
339
339
-
+def test_real_class_attrs_class(real_tuple):
340
340
-
+ """Test class attrs via class level"""
341
341
-
+ obj_type, exp_cimtype = real_tuple
342
342
-
+ assert obj_type.cimtype == exp_cimtype
343
343
-
+
344
344
-
+
345
345
-
+def test_real_class_attrs_inst(real_tuple):
346
346
-
+ """Test class attrs via instance level"""
347
347
-
+ obj_type, exp_cimtype = real_tuple
348
348
-
+ obj = obj_type(42)
349
349
-
+ assert obj.cimtype == exp_cimtype
350
350
-
+
351
351
-
+
352
352
-
+def test_real_inheritance(real_tuple):
353
353
-
+ """Test inheritance"""
354
354
-
+ obj_type = real_tuple[0]
355
355
-
+ obj = obj_type(42)
356
356
-
+ assert isinstance(obj, obj_type)
357
357
-
+ assert isinstance(obj, CIMType)
358
358
-
+ assert isinstance(obj, CIMFloat)
359
359
-
+ assert not isinstance(obj, CIMInt)
360
360
-
+
361
361
-
+
362
362
-
+def test_real_init_float(real_tuple):
363
363
-
+ """Test initialization from floating point value"""
364
364
-
+ obj_type = real_tuple[0]
365
365
-
+ obj = obj_type(42.0)
366
366
-
+ assert obj == 42.0
367
367
-
+
368
368
-
+
369
369
-
+def test_real_init_str(real_tuple):
370
370
-
+ """Test initialization from string value"""
371
371
-
+ obj_type = real_tuple[0]
372
372
-
+ obj = obj_type('42.0')
373
373
-
+ assert obj == 42.0
374
374
-
375
375
-
376
376
-
#
377
377
-
@@ -271,6 +259,26 @@ def test_init_str(real_tuple):
378
378
-
'20140924193040.654321+120'
379
379
-
),
380
380
-
(
381
381
-
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
382
382
-
+ microsecond=654321, tzinfo=MinutesFromUTC(0)),
383
383
-
+ 'timestamp',
384
384
-
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
385
385
-
+ microsecond=654321, tzinfo=MinutesFromUTC(0)),
386
386
-
+ None,
387
387
-
+ 0,
388
388
-
+ '20140924193040.654321+000'
389
389
-
+ ),
390
390
-
+ (
391
391
-
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
392
392
-
+ microsecond=654321),
393
393
-
+ 'timestamp',
394
394
-
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
395
395
-
+ microsecond=654321, tzinfo=MinutesFromUTC(0)),
396
396
-
+ None,
397
397
-
+ 0,
398
398
-
+ '20140924193040.654321+000'
399
399
-
+ ),
400
400
-
+ (
401
401
-
'20140924193040.654321+120',
402
402
-
'timestamp',
403
403
-
datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
404
404
-
@@ -325,46 +333,47 @@ def datetime_init_tuple(request):
405
405
-
return request.param
406
406
-
407
407
-
408
408
-
-class TestDatetime:
409
409
-
- """
410
410
-
- Test CIM real data type classes.
411
411
-
- """
412
412
-
-
413
413
-
- @staticmethod
414
414
-
- def test_class_attrs_class():
415
415
-
- """Test class attrs via class level"""
416
416
-
- assert CIMDateTime.cimtype == 'datetime'
417
417
-
-
418
418
-
- @staticmethod
419
419
-
- def test_class_attrs_inst():
420
420
-
- """Test class attrs via instance level"""
421
421
-
- obj = CIMDateTime('00000000000000.000000:000')
422
422
-
- assert obj.cimtype == 'datetime'
423
423
-
-
424
424
-
- @staticmethod
425
425
-
- def test_inheritance():
426
426
-
- """Test inheritance"""
427
427
-
- obj = CIMDateTime('00000000000000.000000:000')
428
428
-
- assert isinstance(obj, CIMDateTime)
429
429
-
- assert isinstance(obj, CIMType)
430
430
-
- assert not isinstance(obj, CIMFloat)
431
431
-
- assert not isinstance(obj, CIMInt)
432
432
-
-
433
433
-
- @staticmethod
434
434
-
- def test_init(datetime_init_tuple):
435
435
-
- """Test initialization from all input types"""
436
436
-
- (dtarg, exp_kind, exp_datetime, exp_timedelta, exp_minutesfromutc,
437
437
-
- exp_str) = datetime_init_tuple
438
438
-
- try:
439
439
-
- obj = CIMDateTime(dtarg)
440
440
-
- except Exception as exc:
441
441
-
- assert isinstance(exc, exp_kind)
442
442
-
- else:
443
443
-
- assert obj.is_interval == (exp_kind == 'interval')
444
444
-
- assert obj.datetime == exp_datetime
445
445
-
- assert obj.timedelta == exp_timedelta
446
446
-
- assert obj.minutes_from_utc == exp_minutesfromutc
447
447
-
- assert str(obj) == exp_str
448
448
-
+def test_datetime_class_attrs_class():
449
449
-
+ """Test class attrs via class level"""
450
450
-
+ assert CIMDateTime.cimtype == 'datetime'
451
451
-
+
452
452
-
+
453
453
-
+def test_datetime_class_attrs_inst():
454
454
-
+ """Test class attrs via instance level"""
455
455
-
+ obj = CIMDateTime('00000000000000.000000:000')
456
456
-
+ assert obj.cimtype == 'datetime'
457
457
-
+
458
458
-
+
459
459
-
+def test_datetime_inheritance():
460
460
-
+ """Test inheritance"""
461
461
-
+ obj = CIMDateTime('00000000000000.000000:000')
462
462
-
+ assert isinstance(obj, CIMDateTime)
463
463
-
+ assert isinstance(obj, CIMType)
464
464
-
+ assert not isinstance(obj, CIMFloat)
465
465
-
+ assert not isinstance(obj, CIMInt)
466
466
-
+
467
467
-
+
468
468
-
+def test_datetime_init(datetime_init_tuple):
469
469
-
+ """Test initialization from all input types"""
470
470
-
+ (dtarg, exp_kind, exp_datetime, exp_timedelta, exp_minutesfromutc,
471
471
-
+ exp_str) = datetime_init_tuple
472
472
-
+ try:
473
473
-
+ obj = CIMDateTime(dtarg)
474
474
-
+ except Exception as exc:
475
475
-
+ assert isinstance(exc, exp_kind)
476
476
-
+ else:
477
477
-
+ assert obj.is_interval == (exp_kind == 'interval')
478
478
-
+ assert obj.datetime == exp_datetime
479
479
-
+ if obj.datetime is not None:
480
480
-
+ assert isinstance(obj.datetime, datetime)
481
481
-
+ # We ensure that the datetime is always timezone-aware:
482
482
-
+ assert obj.datetime.tzinfo is not None
483
483
-
+ assert obj.timedelta == exp_timedelta
484
484
-
+ if obj.timedelta is not None:
485
485
-
+ assert isinstance(obj.timedelta, timedelta)
486
486
-
+ assert obj.minutes_from_utc == exp_minutesfromutc
487
487
-
+ assert str(obj) == exp_str
488
488
-
+
489
489
-
490
490
-
# TODO: Add testcases for get_local_utcoffset()
491
491
-
# TODO: Add testcases for now()
+1
-2
pkgs/top-level/python-packages.nix
···
4842
4842
ROPGadget = callPackage ../development/python-modules/ROPGadget { };
4843
4843
4844
4844
# We need "normal" libxml2 and not the python package by the same name.
4845
4845
-
pywbem = disabledIf isPy36
4846
4846
-
(callPackage ../development/python-modules/pywbem { libxml2 = pkgs.libxml2; });
4845
4845
+
pywbem = callPackage ../development/python-modules/pywbem { libxml2 = pkgs.libxml2; };
4847
4846
4848
4847
unicorn = callPackage ../development/python-modules/unicorn { };
4849
4848