Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ target/
profile_default/
ipython_config.py

# Launchable
.launchable.d/

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
Expand Down
9 changes: 5 additions & 4 deletions launchable_cli_args/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def fill_and_validate(self, data: dict, error_counter: ErrorCounter):
"one of target/confidence/time must be specified")

def write_to(self, writer: YamlWriter):
writer.comment("mode is subset, subset-and-rest, or record-only")
writer.comment("mode can be subset, subset-and-rest, or record-only")
writer.name("mode").value(self.mode)

writer.comment("you must specify one of target/confidence/time")
writer.comment(
"if mode is subset or subset-and-rest, you must specify one of target/confidence/time")
writer.comment("examples:")
writer.comment(
" target: 30% # Create a variable time-based subset of the given percentage. (0%-100%)")
Expand Down Expand Up @@ -68,6 +69,6 @@ def to_command(self) -> "Commands":
@classmethod
def auto_configure(cls, parent: 'CLIArgs', path: str) -> "SubsetArgs":
a = SubsetArgs(parent)
a.target = "30%"
a.mode = "subset"
a.mode = "record-only"
a.confidence = 99
return a
8 changes: 4 additions & 4 deletions pytest_launchable/launchable_test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def init_launchable_test_context(items: List[pytest.Function]) -> "LaunchableTes

# called for each test file... this hook can be used to collect full path of tests
# def pytest_collect_file(path):
# print("collect_file path=%s testcasecount=%d" % (path, len(lc.test_node_list))) # 'path' is full path
# print("collect_file path=%s testcasecount=%d" % (path, len(lc.test_node_list))) # 'path' is full path

# this hook receives test case list
# we get a chance of reordering or subsetting at this point
Expand Down Expand Up @@ -309,9 +309,9 @@ def pytest_collection_modifyitems(config, items: List[pytest.Function]) -> None:
raw_subset_result.stdout, cli.subset.REST_FILE_NAME)
else:
lc.set_subset_command_response(raw_subset_result.stdout)
#print("input_file_list=" + str(file_list))
#print("output_file_list=" + str(lc.subset_list))
#print("all collected names " + str(lc.to_name_tuple_list()))
# print("input_file_list=" + str(file_list))
# print("output_file_list=" + str(lc.subset_list))
# print("all collected names " + str(lc.to_name_tuple_list()))

# find testcase , mark category name, and return pytest object
def find_and_mark(nodeid: str, category: str):
Expand Down
17 changes: 9 additions & 8 deletions tests/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ def test_command() -> None:
args = CLIArgs.auto_configure("tests")
args.build_id = "XXX" # manually configured build id

# at the present, test only subset mode command.
# at present, test only subset mode command.

# default is subset mode
# record-only mode (default) / skip subset service, record test command only
args.subset.mode = "record-only"
assert args.subset.to_command() == ()

# subset mode
args.subset.mode = "subset"
assert args.subset.to_command() == ("launchable", "subset", "--build",
"XXX", "--target", "30%", "pytest")
"XXX", "--confidence", 99, "pytest")

# subset-and-rest mode
args.subset.mode = "subset-and-rest"
assert args.subset.to_command() == ("launchable", "subset", "--build", "XXX",
"--target", "30%", "--rest", args.subset.REST_FILE_NAME, "pytest")

# record-only mode / skip subset service, record test command only
args.subset.mode = "record-only"
assert args.subset.to_command() == ()
"--confidence", 99, "--rest", args.subset.REST_FILE_NAME, "pytest")
4 changes: 2 additions & 2 deletions tests/test_launchable_pytest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable
from typing import Optional, Callable
import pytest
from pytest_launchable.launchable_test_context import PytestTestPath, init_launchable_test_context, parse_pytest_item

Expand All @@ -18,7 +18,7 @@ def m(self):
class PseudoPytest:
"""make pseudo pytest item"""

def __init__(self, file: str, name: str, func_or_method: Callable, parameters: str = None):
def __init__(self, file: str, name: str, func_or_method: Callable, parameters: Optional[str] = None):
class_name = func_or_method.__self__.__class__.__name__ if hasattr( # type: ignore
func_or_method, "__self__") else None
function = name + f'[{parameters}]' if parameters else name
Expand Down
4 changes: 2 additions & 2 deletions tests/test_yaml_write_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from yaml2obj.loader import YamlLoaderWithLineNumber
from yaml2obj.writer import YamlWriter

# Write YAML and read it with line numbers
#  Write YAML and read it with line numbers


def test_yaml_read_write():
Expand All @@ -15,7 +15,7 @@ def test_yaml_read_write():


# expected yaml
#key0: value0
# key0: value0
# key1:
# key11: value11

Expand Down