def test_web(app):
    client = app.test_client()
    response = client.post(
        '/user/sign-in?next=/',
        follow_redirects=True,
        data=dict(
            username='test@test.com',
            password='Password1'
        )
    )
    response = client.get('/')
    assert response.status_code == 200
    assert b"<title>Training stats</title>" in response.data

def login(client):
    response = client.post(
        '/user/sign-in?next=/',
        follow_redirects=True,
        data=dict(
            username='test@test.com',
            password='Password1'
        )
    )
    return response

def test_navigating_to_startpage(app):
    client = app.test_client()
    login(client)
    response = client.get('/')
    assert response.status_code == 200
    assert b"<title>Training stats</title>" in response.data

Refactor test to be more clear
Refactor test to be more clear

+ def login(client):
- def test_web(app):
-     client = app.test_client()
      response = client.post(
          '/user/sign-in?next=/',
          follow_redirects=True,
          data=dict(
              username='test@test.com',
              password='Password1'
          )
      )
+     return response
+ 
+ def test_navigating_to_startpage(app):
+     client = app.test_client()
+     login(client)
      response = client.get('/')
      assert response.status_code == 200
      assert b"<title>Training stats</title>" in response.data
  
Refactor test to be more clear
## Code Before:
def test_web(app):
    client = app.test_client()
    response = client.post(
        '/user/sign-in?next=/',
        follow_redirects=True,
        data=dict(
            username='test@test.com',
            password='Password1'
        )
    )
    response = client.get('/')
    assert response.status_code == 200
    assert b"<title>Training stats</title>" in response.data

## Instruction:
Refactor test to be more clear
## Code After:
def login(client):
    response = client.post(
        '/user/sign-in?next=/',
        follow_redirects=True,
        data=dict(
            username='test@test.com',
            password='Password1'
        )
    )
    return response

def test_navigating_to_startpage(app):
    client = app.test_client()
    login(client)
    response = client.get('/')
    assert response.status_code == 200
    assert b"<title>Training stats</title>" in response.data
