Skip to content

Commit 85589b9

Browse files
committed
Make the tests a bit more robust
1 parent caec069 commit 85589b9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

webware/MiscUtils/Tests/TestFuncs.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ def testLocalIP(self):
9090
self.assertFalse(ip.startswith('127.'))
9191
self.assertEqual(localIP(), ip) # second invocation
9292
self.assertEqual(localIP(useCache=None), ip)
93-
self.assertEqual(
94-
localIP(remote=None, useCache=None), ip,
93+
# ignore if the following tests fetch the WSL address
94+
ips = (ip, '192.168.80.1', '172.25.112.1')
95+
self.assertIn(
96+
localIP(remote=None, useCache=None), ips,
9597
'See if this works: localIP(remote=None).'
9698
' If this fails, dont worry.')
97-
self.assertEqual(
99+
self.assertIn(
98100
localIP(remote=('www.hostname.and.domain.are.invalid', 80),
99-
useCache=None), ip)
101+
useCache=None), ips)
100102

101103
def testPositiveId(self):
102104
# About all we can do is invoke positiveId()

webware/Tests/TestEndToEnd/TestExamples.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import unittest
5+
from time import sleep
56

67
from .AppTest import AppTest
78

@@ -19,7 +20,11 @@ def setUp(self):
1920
@staticmethod
2021
def removeDemoDatabase():
2122
if os.path.exists('demo.db'):
22-
os.remove('demo.db')
23+
try:
24+
os.remove('demo.db')
25+
except OSError:
26+
sleep(1)
27+
os.remove('demo.db')
2328

2429
def testStartPage(self):
2530
r = self.testApp.get('/')

0 commit comments

Comments
 (0)