From d809ed02221ccd56b3450bf8a6c187b7257e2cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillem=20Pag=C3=A8s?= Date: Sat, 21 Mar 2020 20:36:41 +0100 Subject: [PATCH] Implement tests as standalone functions Tests should not be wrapped in a class. --- .../test_tankerkoenig_validators.py | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/tests/components/tankerkoenig/test_tankerkoenig_validators.py b/tests/components/tankerkoenig/test_tankerkoenig_validators.py index 7dba88b24fb30..fab56e6d75670 100755 --- a/tests/components/tankerkoenig/test_tankerkoenig_validators.py +++ b/tests/components/tankerkoenig/test_tankerkoenig_validators.py @@ -1,5 +1,4 @@ """The tests for the custom tankerkoenig validators.""" -import unittest import uuid import pytest @@ -8,25 +7,22 @@ from homeassistant.components.tankerkoenig import uuid4_string -class TestUUID4StringValidator(unittest.TestCase): - """Test the UUID4 string custom validator.""" - - def test_uuid4_string(caplog): - """Test string uuid validation.""" - schema = vol.Schema(uuid4_string) - - for value in ["Not a hex string", "0", 0]: - with pytest.raises(vol.Invalid): - schema(value) +def test_uuid4_string(caplog): + """Test string uuid validation.""" + schema = vol.Schema(uuid4_string) + for value in ["Not a hex string", "0", 0]: with pytest.raises(vol.Invalid): - # the third block should start with 4 - schema("a03d31b2-2eee-2acc-bb90-eec40be6ed23") + schema(value) - with pytest.raises(vol.Invalid): - # the fourth block should start with 8-a - schema("a03d31b2-2eee-4acc-1b90-eec40be6ed23") + with pytest.raises(vol.Invalid): + # the third block should start with 4 + schema("a03d31b2-2eee-2acc-bb90-eec40be6ed23") + + with pytest.raises(vol.Invalid): + # the fourth block should start with 8-a + schema("a03d31b2-2eee-4acc-1b90-eec40be6ed23") - _str = str(uuid.uuid4()) - assert schema(_str) == _str - assert schema(_str.upper()) == _str + _str = str(uuid.uuid4()) + assert schema(_str) == _str + assert schema(_str.upper()) == _str