Skip to content

tests: metrics tests fail when PYTHONWARNINGS="ignore" #993

Closed
@michaelbrewer

Description

@michaelbrewer

What were you trying to accomplish?

Run make test when PYTHONWARNINGS="ignore"

Expected Behavior

Test should pass

Current Behavior

_____________________________________________________________________________________________________ test_log_metrics_decorator_no_metrics_warning _____________________________________________________________________________________________________

dimensions = [{'name': 'test_dimension', 'value': 'test'}, {'name': 'test_dimension_2', 'value': 'test'}], namespace = 'test_namespace', service = 'test_service'

    def test_log_metrics_decorator_no_metrics_warning(dimensions, namespace, service):
        # GIVEN Metrics is initialized
        my_metrics = Metrics(namespace=namespace, service=service)
    
        # WHEN using the log_metrics decorator and no metrics have been added
        @my_metrics.log_metrics
        def lambda_handler(evt, context):
            pass
    
        # THEN it should raise a warning instead of throwing an exception
        with warnings.catch_warnings(record=True) as w:
            lambda_handler({}, {})
>           assert len(w) == 1
E           assert 0 == 1
E             +0
E             -1

tests/functional/test_metrics.py:555: AssertionError

Possible Solution

Temp set warnings.simplefilter("default")

Steps to Reproduce (for bugs)

  1. export PYTHONWARNINGS="ignore"
  2. make test

Environment

  • Powertools version used:
  • Packaging format (Layers, PyPi):
  • AWS Lambda function runtime:
  • Debugging logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions