Merge "Reduce reliance on global state for testing"

This commit is contained in:
Jenkins 2016-05-31 19:39:57 +00:00 committed by Gerrit Code Review
commit d469654d51
2 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@
# (c) 2014, Kevin Carter <kevin.carter@rackspace.com>
import argparse
import copy
import datetime
import json
import netaddr
@ -1079,7 +1080,7 @@ def main(all_args):
backup_name = '%s-%s.json' % (basename, utctime)
tar.add(dynamic_inventory_file, arcname=backup_name)
else:
dynamic_inventory = INVENTORY_SKEL
dynamic_inventory = copy.deepcopy(INVENTORY_SKEL)
# Save the users container cidr as a group variable
cidr_networks = user_defined_config.get('cidr_networks')

View File

@ -316,6 +316,10 @@ class TestIps(unittest.TestCase):
"""Test that no duplicate IPs are made on any network."""
for i in xrange(0, 99):
# tearDown is ineffective for this loop, so clean the USED_IPs
# on each run
inventory = None
di.USED_IPS = []
inventory = get_inventory()
ips = collections.defaultdict(int)
hostvars = inventory['_meta']['hostvars']