Skip to content

Commit

Permalink
Fix readme_example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdb9696 committed Jul 29, 2024
1 parent 8563db0 commit 0548ddd
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions kasa/tests/test_readme_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import sys

import pytest
import xdoctest
Expand Down Expand Up @@ -69,79 +70,109 @@ def test_discovery_examples(readmes_mock):
"""Test discovery examples."""
res = xdoctest.doctest_module("kasa.discover", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_deviceconfig_examples(readmes_mock):
"""Test discovery examples."""
res = xdoctest.doctest_module("kasa.deviceconfig", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_device_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.device", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_light_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.interfaces.light", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_light_preset_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.interfaces.lightpreset", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_light_effect_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.interfaces.lighteffect", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_child_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.smart.modules.childdevice", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_module_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.module", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_feature_examples(readmes_mock):
"""Test device examples."""
res = xdoctest.doctest_module("kasa.feature", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


def test_tutorial_examples(readmes_mock):
"""Test discovery examples."""
res = xdoctest.doctest_module("docs/tutorial.py", "all")
assert res["n_passed"] > 0
assert res["n_warned"] == 0
if sys.version_info < (3, 13):
# xdoctest raises DeprecationWarning: 'count' is passed as positional argument
# in checker.py: new_text = re.sub(blankline_pattern, '\n', text, re.MULTILINE)
assert res["n_warned"] == 0
assert not res["failed"]


Expand Down

0 comments on commit 0548ddd

Please sign in to comment.