def test_counter_totals(self): counter.reset() counter.add(1) counter.add(2) counter.add(3) counter.add(1) self.assertEqual(counter.totals(), [(1, 2), (2, 1), (3, 1)])
def hello(): if counter.getCount("counter") == 5: counter.reset("counter") return "y" else: counter.increment("counter") return "n"
def test_range_totals(self): counter.reset([0, 5, 10, 15]) counter.add(3) counter.add(9) counter.add(4.5) counter.add(12) counter.add(14.2) counter.add(8) self.assertEqual(counter.totals(), [(0, 5, 2), (5, 10, 2), (10, 15, 2)])
def test_counter_range(self): counter.reset([0, 5, 10, 15]) counter.add(5.7) counter.add(4.6) counter.add(14.2) counter.add(0.3) counter.add(7.1) counter.add(2.6) print(counter.totals()) self.assertEqual(counter.totals(), [(0, 5, 3), (5, 10, 2), (10, 15, 1)])
def test_out_of_range(self): counter.reset([0, 5, 10, 15]) with self.assertRaises(RuntimeError): counter.add(19.1)
def test_counter_reset(self): counter.reset() counter.add(1) counter.reset() counter.add(2) self.assertEqual(counter.totals(), [(2, 1)])
thread1.join() if (version == "4" or version==""): call('umount /mnt/ganesha-mnt',shell=True) mount(export,server_ip,"4") if os.path.ismount('/mnt/ganesha-mnt') == False: if version == "4": print "v4 mount failed,exiting." sys.exit(1) else: print "v4 mount failed, skipping v4 tests" else: nfs4_total = len(test_list) print "==============================Running v4 tests==============================" counter.reset(); run_tests(test_list) print_results(nfs4_total); if (version == "3" or version==""): call('umount /mnt/ganesha-mnt',shell=True) mount(export,server_ip,"3") if os.path.ismount('/mnt/ganesha-mnt') == False: print "v3 mount failed,exiting." sys.exit(1) if "pynfs_tests.py" in test_list: test_list.remove("pynfs_tests.py") nfs3_total = len(test_list) print "==============================Running v3 tests==============================" counter.reset(); run_tests(test_list) print_results(nfs3_total);
thread1.join() if (version == "4" or version == ""): call('umount /mnt/ganesha-mnt', shell=True) mount(export, server_ip, "4") if os.path.ismount('/mnt/ganesha-mnt') == False: if version == "4": print "v4 mount failed,exiting." sys.exit(1) else: print "v4 mount failed, skipping v4 tests" else: nfs4_total = len(test_list) print "==============================Running v4 tests==============================" counter.reset() run_tests(test_list) print_results(nfs4_total) if (version == "3" or version == ""): call('umount /mnt/ganesha-mnt', shell=True) mount(export, server_ip, "3") if os.path.ismount('/mnt/ganesha-mnt') == False: print "v3 mount failed,exiting." sys.exit(1) if "pynfs_tests.py" in test_list: test_list.remove("pynfs_tests.py") nfs3_total = len(test_list) print "==============================Running v3 tests==============================" counter.reset() run_tests(test_list) print_results(nfs3_total)