Skip to content

Commit

Permalink
test parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed May 19, 2017
1 parent 30119a0 commit b7cbbf6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions ippy/ippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ def worker_func(ping_args, pending, done):
while True:
# Get the next address to ping.
address = pending.get_nowait()

print('test')
ping = subprocess.Popen(ping_args + [address],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
print('test2')
out, error = ping.communicate()

print('test3')
# Output the result to the 'done' queue.
done.put(({'result': out, 'ip': address}, error))
print('test4')
except queue.Empty:
# No more addresses.
pass
Expand Down
8 changes: 4 additions & 4 deletions tests/test_ippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_filepath():

def test_run():
ippt = ippy.Ippy()
ippt.set_config(True, 'csv', 10)
ippt.set_config(True, 'csv', 1)
ippt.set_file(file='ip_list.csv')
ippt.run()

Expand All @@ -78,7 +78,7 @@ def test_run():

def test_empty_result():
ippt = ippy.Ippy()
ippt.set_config(False, 'test', 10)
ippt.set_config(False, 'test', 1)
ippt.set_file(file='ip_list.csv')
ippt.run()
with pytest.raises(ValueError):
Expand All @@ -87,14 +87,14 @@ def test_empty_result():

def test_json_result():
ippt = ippy.Ippy()
ippt.set_config(False, 'json', 10)
ippt.set_config(False, 'json', 1)
result = ippt.result()
assert json.loads(result) is not None


def test_csv_result():
ippt = ippy.Ippy()
ippt.set_config(False, 'csv', 10)
ippt.set_config(False, 'csv', 1)
ippt.set_file(file='ip_list.csv')
ippt.run()
result = ippt.result()
Expand Down

0 comments on commit b7cbbf6

Please sign in to comment.