11"""Test Configuration"""
22# pylint: disable=missing-function-docstring
33
4- import sys
54from distutils .dir_util import copy_tree
65from pathlib import Path
76
87import pytest
98
109import appmap
1110import appmap ._implementation
12- import appmap ._implementation .env as impl_env
1311from appmap ._implementation .configuration import Config , ConfigFilter
1412from appmap ._implementation .env import Env
1513from appmap ._implementation .importer import Filterable , NullFilter
@@ -47,28 +45,21 @@ def test_reports_invalid():
4745 assert not Config ().file_valid
4846
4947
48+ @pytest .mark .appmap_enabled (config = "appmap-broken.yml" , appmap_enabled = None )
5049def test_is_disabled_when_unset ():
5150 """Test that recording is disabled when APPMAP is unset"""
5251 assert Env .current .get ("APPMAP" , None ) is None
5352
5453 assert not appmap .enabled ()
5554
5655
56+ @pytest .mark .appmap_enabled (config = "appmap-broken.yml" , appmap_enabled = "false" )
5757def test_is_disabled_when_false ():
5858 """Test that recording is disabled when APPMAP=false"""
5959 Env .current .set ("APPMAP" , "false" )
6060 assert not appmap .enabled ()
6161
6262
63- @pytest .mark .appmap_enabled (appmap_enabled = None )
64- def test_is_disabled_with_valid_config ():
65- c = Config ()
66- assert c .file_present
67- assert c .file_valid
68-
69- assert not appmap .enabled ()
70-
71-
7263def test_config_not_found (caplog ):
7364 appmap ._implementation .initialize (
7465 env = { # pylint: disable=protected-access
@@ -86,15 +77,16 @@ def test_config_not_found(caplog):
8677 assert f'"{ not_found } " is missing' in caplog .text
8778
8879
80+ @pytest .mark .appmap_enabled (appmap_enabled = "false" , config = "notfound.yml" )
8981def test_config_no_message (caplog ):
9082 """
9183 Messages about a missing config should only be logged when
9284 recording is enabled
9385 """
9486
95- assert Config ().name is None
9687 assert not appmap .enabled ()
97- assert caplog .text is ""
88+ assert Config ().name is None
89+ assert caplog .text == ""
9890
9991
10092cf = lambda : ConfigFilter (NullFilter ())
@@ -200,6 +192,7 @@ def test_created_if_missing_and_enabled(self, git, data_dir, monkeypatch):
200192 assert path .is_file ()
201193
202194 def test_not_created_if_missing_and_not_enabled (self , git , data_dir , monkeypatch ):
195+ monkeypatch .setenv ("APPMAP" , "false" )
203196 repo_root = git .cwd
204197 copy_tree (data_dir / "config" , str (repo_root ))
205198 monkeypatch .chdir (repo_root )
@@ -208,7 +201,7 @@ def test_not_created_if_missing_and_not_enabled(self, git, data_dir, monkeypatch
208201 assert not path .is_file ()
209202
210203 # pylint: disable=protected-access
211- appmap ._implementation .initialize (cwd = repo_root , env = { "APPMAP" : "false" } )
204+ appmap ._implementation .initialize (cwd = repo_root )
212205
213206 c = Config ()
214207 assert not path .is_file ()
0 commit comments