mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Modify tests to use pytest fixture
This commit is contained in:
@@ -27,15 +27,15 @@ class CmdVersion(CmdBase):
|
||||
|
||||
|
||||
def add_parser(subparsers, parent_parser):
|
||||
ADD_HELP = (
|
||||
VERSION_HELP = (
|
||||
"Output the system/environment information along with the DVC version"
|
||||
)
|
||||
|
||||
add_parser = subparsers.add_parser(
|
||||
"version",
|
||||
parents=[parent_parser],
|
||||
description=append_doc_link(ADD_HELP, "version"),
|
||||
help=ADD_HELP,
|
||||
description=append_doc_link(VERSION_HELP, "version"),
|
||||
help=VERSION_HELP,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
add_parser.set_defaults(func=CmdVersion)
|
||||
|
||||
+18
-12
@@ -1,20 +1,26 @@
|
||||
from dvc.main import main
|
||||
import re
|
||||
|
||||
from dvc.command.version import CmdVersion
|
||||
from dvc.cli import parse_args
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
|
||||
def test_run():
|
||||
cmd = CmdVersion(parse_args(["version"]))
|
||||
ret = cmd.run_cmd()
|
||||
assert ret == 0
|
||||
|
||||
|
||||
class TestVersion(TestDvc):
|
||||
def test_run(self):
|
||||
ret = main(["version"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
|
||||
def test_info(dvc, mocker, caplog):
|
||||
def test_info(caplog):
|
||||
check_data = ["DVC version", "Python version", "Platform"]
|
||||
cmd = CmdVersion(parse_args(["version"]))
|
||||
cmd.run()
|
||||
info_dict = {}
|
||||
|
||||
for record in caplog.records:
|
||||
assert "DVC version" in record.msg
|
||||
assert "Python version" in record.msg
|
||||
assert "Platform" in record.msg
|
||||
msg = re.sub(r"\n", ": ", record.msg)
|
||||
info_list = msg.split(": ")
|
||||
for i in range(0, len(info_list), 2):
|
||||
info_dict[info_list[i]] = info_list[i + 1]
|
||||
|
||||
for info_type in check_data:
|
||||
assert re.match(r".*", info_dict.get(info_type))
|
||||
|
||||
Reference in New Issue
Block a user