Skip to content

Commit 567ef17

Browse files
author
David Noble
committed
Windows test fixes
1 parent 0ab0918 commit 567ef17

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

examples/searchcommands_app/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def run(self):
320320
os.mkdir(packages)
321321

322322
splunklib = os.path.join(packages, 'splunklib')
323-
source = os.path.join(project_dir, '..', '..', 'splunklib')
323+
source = os.path.normpath(os.path.join(project_dir, '..', '..', 'splunklib'))
324324

325325
if os.path.islink(splunklib):
326326
os.remove(splunklib)

splunklib/searchcommands/internals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def validate_configuration_setting(specification, name, value):
290290
supporting_protocols=[1]),
291291
'maxinputs': specification(
292292
type=int,
293-
constraint=lambda value: 0 <= value <= sys.maxsize,
293+
constraint=lambda value: 0 <= value <= sys.maxint,
294294
supporting_protocols=[2]),
295295
'overrides_timeorder': specification(
296296
type=bool,

splunklib/searchcommands/validators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ class File(Validator):
122122
""" Validates file option values.
123123
124124
"""
125-
def __init__(self, mode='rt', buffering=None):
125+
def __init__(self, mode='rt', buffering=None, directory=None):
126126
self.mode = mode
127127
self.buffering = buffering
128+
self.directory = File._var_run_splunk if directory is None else directory
128129

129130
def __call__(self, value):
130131

@@ -134,7 +135,7 @@ def __call__(self, value):
134135
path = unicode(value)
135136

136137
if not os.path.isabs(path):
137-
path = os.path.join(File._var_run_splunk, path)
138+
path = os.path.join(self.directory, path)
138139

139140
try:
140141
value = open(path, self.mode) if self.buffering is None else open(path, self.mode, self.buffering)

tests/searchcommands/test_decorators.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,14 @@ def test_option(self):
419419

420420
expected = (
421421
'foo="f" boolean="f" code="foo == \\"bar\\"" duration="24:59:59" fieldname="some.field_name" '
422-
'file="' + __file__ + '" integer="100" map="foo" match="123-45-6789" optionname="some_option_name" '
423-
'record="f" regularexpression="\\\\s+" required_boolean="f" required_code="foo == \\"bar\\"" '
424-
'required_duration="24:59:59" required_fieldname="some.field_name" required_file="' + __file__ + '" '
425-
'required_integer="100" required_map="foo" required_match="123-45-6789" '
426-
'required_optionname="some_option_name" required_regularexpression="\\\\s+" required_set="bar" set="bar" '
427-
'show_configuration="f"')
428-
429-
observed = str(command.options)
422+
'file=' + json_encode_string(__file__) + ' integer="100" map="foo" match="123-45-6789" '
423+
'optionname="some_option_name" record="f" regularexpression="\\\\s+" required_boolean="f" '
424+
'required_code="foo == \\"bar\\"" required_duration="24:59:59" required_fieldname="some.field_name" '
425+
'required_file=' + json_encode_string(__file__) + ' required_integer="100" required_map="foo" '
426+
'required_match="123-45-6789" required_optionname="some_option_name" required_regularexpression="\\\\s+" '
427+
'required_set="bar" set="bar" show_configuration="f"')
428+
429+
observed = unicode(command.options)
430430

431431
self.assertEqual(observed, expected)
432432
return

tests/testlib.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,19 @@ def setUp(self):
246246
logging.debug("Connected to splunkd version %s", '.'.join(str(x) for x in self.service.splunk_version))
247247

248248
def tearDown(self):
249+
from urllib2 import HTTPError
250+
249251
if self.service.restart_required:
250252
self.fail("Test left Splunk in a state requiring a restart.")
253+
251254
for appName in self.installedApps:
252255
if appName in self.service.apps:
253-
self.service.apps.delete(appName)
256+
try:
257+
self.service.apps.delete(appName)
258+
except HTTPError as error:
259+
print error
260+
pass
254261
wait(lambda: appName not in self.service.apps)
262+
255263
if self.service.restart_required:
256264
self.clear_restart_message()

0 commit comments

Comments
 (0)