Skip to content

Commit

Permalink
Merge pull request psf#21 from gaul/test/localhost
Browse files Browse the repository at this point in the history
Replace localhost with constant
  • Loading branch information
kevin1024 authored Aug 31, 2023
2 parents 9a3dd89 + acc5d72 commit ba1b151
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/test_httpbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ def test_get(self):
self.assertEqual(response.status_code, 200)
data = json.loads(response.data.decode('utf-8'))
self.assertEqual(data['args'], {})
self.assertEqual(data['headers']['Host'], 'localhost')
self.assertEqual(data['headers']['User-Agent'], 'test')
# self.assertEqual(data['origin'], None)
self.assertEqual(data['url'], 'http://localhost/get')
self.assertRegex(data['url'], '^http://[^/]*/get$')
self.assertTrue(response.data.endswith(b'\n'))

def test_anything(self):
Expand All @@ -159,8 +158,7 @@ def test_anything(self):
self.assertEqual(response.status_code, 200)
data = json.loads(response.data.decode('utf-8'))
self.assertEqual(data['args'], {})
self.assertEqual(data['headers']['Host'], 'localhost')
self.assertEqual(data['url'], 'http://localhost/anything/foo/bar')
self.assertRegex(data['url'], '^http://[^/]*/anything/foo/bar$')
self.assertEqual(data['method'], 'GET')
self.assertTrue(response.data.endswith(b'\n'))

Expand Down Expand Up @@ -581,8 +579,8 @@ def test_redirect_to_post(self):

def test_redirect_absolute_param_n_higher_than_1(self):
response = self.app.get('/redirect/5?absolute=true')
self.assertEqual(
response.headers.get('Location'), 'http://localhost/absolute-redirect/4'
self.assertRegex(
response.headers.get('Location'), '^http://[^/]*/absolute-redirect/4$'
)

def test_redirect_n_equals_to_1(self):
Expand All @@ -607,15 +605,15 @@ def test_relative_redirect_n_higher_than_1(self):

def test_absolute_redirect_n_higher_than_1(self):
response = self.app.get('/absolute-redirect/5')
self.assertEqual(
response.headers.get('Location'), 'http://localhost/absolute-redirect/4'
self.assertRegex(
response.headers.get('Location'), '^http://[^/]*/absolute-redirect/4$'
)

def test_absolute_redirect_n_equals_to_1(self):
response = self.app.get('/absolute-redirect/1')
self.assertEqual(response.status_code, 302)
self.assertEqual(
response.headers.get('Location'), 'http://localhost/get'
self.assertRegex(
response.headers.get('Location'), '^http://[^/]*/get$'
)

def test_request_range(self):
Expand Down

0 comments on commit ba1b151

Please sign in to comment.