import pytest

from calc import INTEGER, Token


def test_no_defaults():
    # There's no valid defaults at the moment.
    with pytest.raises(TypeError):
        Token()


def test_known_type():
    # There's no valid defaults at the moment.
    token = Token(type=INTEGER, value=2)
    assert token.value == 2
    assert token.type == INTEGER


def test_str_non_string_value():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert token.__str__() == expected_result


def test_repr():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert token.__repr__() == expected_result

import pytest

from calc import INTEGER, Token


def test_no_defaults():
    # There's no valid defaults at the moment.
    with pytest.raises(TypeError):
        Token()


def test_known_type():
    # There's no valid defaults at the moment.
    token = Token(type=INTEGER, value=2)
    assert token.value == 2
    assert token.type == INTEGER


def test_str_non_string_value():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert str(token) == expected_result


def test_repr():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert repr(token) == expected_result

Use str and repr functions instead of magic methods
Use str and repr functions instead of magic methods

  import pytest
  
  from calc import INTEGER, Token
  
  
  def test_no_defaults():
      # There's no valid defaults at the moment.
      with pytest.raises(TypeError):
          Token()
  
  
  def test_known_type():
      # There's no valid defaults at the moment.
      token = Token(type=INTEGER, value=2)
      assert token.value == 2
      assert token.type == INTEGER
  
  
  def test_str_non_string_value():
      token = Token(type=INTEGER, value=2)
      expected_result = "Token(type=INTEGER, value=2)"
-     assert token.__str__() == expected_result
+     assert str(token) == expected_result
  
  
  def test_repr():
      token = Token(type=INTEGER, value=2)
      expected_result = "Token(type=INTEGER, value=2)"
-     assert token.__repr__() == expected_result
+     assert repr(token) == expected_result
  
Use str and repr functions instead of magic methods
## Code Before:
import pytest

from calc import INTEGER, Token


def test_no_defaults():
    # There's no valid defaults at the moment.
    with pytest.raises(TypeError):
        Token()


def test_known_type():
    # There's no valid defaults at the moment.
    token = Token(type=INTEGER, value=2)
    assert token.value == 2
    assert token.type == INTEGER


def test_str_non_string_value():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert token.__str__() == expected_result


def test_repr():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert token.__repr__() == expected_result

## Instruction:
Use str and repr functions instead of magic methods
## Code After:
import pytest

from calc import INTEGER, Token


def test_no_defaults():
    # There's no valid defaults at the moment.
    with pytest.raises(TypeError):
        Token()


def test_known_type():
    # There's no valid defaults at the moment.
    token = Token(type=INTEGER, value=2)
    assert token.value == 2
    assert token.type == INTEGER


def test_str_non_string_value():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert str(token) == expected_result


def test_repr():
    token = Token(type=INTEGER, value=2)
    expected_result = "Token(type=INTEGER, value=2)"
    assert repr(token) == expected_result
