Skip to content

Commit ae9cad2

Browse files
authored
Fix error messages in test cases (#26)
1 parent 1c220af commit ae9cad2

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

libs/amp-instrumentation/tests/test_cli.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ def test_bootstrap_directory_not_found(self, tmp_path):
101101

102102
# Check that error message was printed to stderr
103103
stderr_output = mock_stderr.getvalue()
104-
assert "Error: Bootstrap directory not found" in stderr_output
105-
assert "Package may not be properly installed" in stderr_output
104+
assert "Error: Package installation is incomplete" in stderr_output
106105
assert "pip install --force-reinstall" in stderr_output
107106

108107

@@ -131,10 +130,8 @@ def test_warns_when_sitecustomize_exists(self, tmp_path):
131130

132131
stderr_output = mock_stderr.getvalue()
133132
# Verify warning was printed
134-
assert "Warning: Found existing sitecustomize.py" in stderr_output
135-
assert (
136-
"This may conflict with WSO2 AMP instrumentation" in stderr_output
137-
)
133+
assert "Warning: Found sitecustomize.py" in stderr_output
134+
assert "may conflict with instrumentation" in stderr_output
138135
finally:
139136
os.chdir(original_cwd)
140137

libs/amp-instrumentation/tests/test_initialization.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_missing_variable_raises_error(self, clean_environment):
3030
with pytest.raises(initialization.ConfigurationError) as exc_info:
3131
initialization._get_required_env_var("MISSING_VAR")
3232
assert "MISSING_VAR" in str(exc_info.value)
33-
assert "not set or is empty" in str(exc_info.value)
33+
assert "is required but not set" in str(exc_info.value)
3434

3535
def test_empty_variable_raises_error(self, clean_environment):
3636
"""Test that empty variable raises ConfigurationError."""
@@ -54,9 +54,7 @@ def test_successful_initialization(self, clean_environment, mock_traceloop):
5454
"""Test successful initialization with all required env vars."""
5555
# Set required environment variables
5656
os.environ[env_vars.AMP_AGENT_NAME] = "test-app"
57-
os.environ[env_vars.AMP_OTEL_ENDPOINT] = (
58-
"https://otel.example.com"
59-
)
57+
os.environ[env_vars.AMP_OTEL_ENDPOINT] = "https://otel.example.com"
6058
os.environ[env_vars.AMP_AGENT_API_KEY] = "test-key"
6159

6260
# Reset initialization state

libs/amp-instrumentation/tests/test_sitecustomize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def test_sitecustomize_initialization_failure_exits_with_error():
4444
assert result.returncode == 1, "Expected exit code 1 when initialization fails"
4545

4646
# Should print error message to stderr
47-
assert "ERROR: WSO2 AMP instrumentation failed" in result.stderr
48-
assert "Check your environment variables and configuration" in result.stderr
47+
assert "Error: Environment variable" in result.stderr
48+
assert "is required but not set" in result.stderr
4949

5050

5151
def test_sitecustomize_successful_initialization():

0 commit comments

Comments
 (0)