terraform-compliance / cli

a lightweight, security focused, BDD test framework against terraform.
https://terraform-compliance.com
MIT License
1.34k stars 151 forks source link

DeprecationWarning: datetime.datetime.utcnow() on version 1.3.48 (using python 3.12) #733

Open rui1610 opened 2 weeks ago

rui1610 commented 2 weeks ago

Description

When running terraform_compliance 1.3.48 with python 3.12 I'm getting multiple DeprecationWarnings on the usage of datetime.datetime.utcnow().

Although terraform_compliance still works, this makes it difficult to read the output.

To Reproduce

Just run terraform_compliance with any feature file on python 3.12

Feature File:

Given I have ....
When it contains ...
Then it must ....
And it must ...

Plan File:

Sample Terraform Code:

resource "aws_s3_bucket" "example_code" {
   bucket = "This is just a sample code"
}

Used terraform-compliance Parameters:

Running via Docker:

Yes

Error Output:

. Converting terraform plan file.
🚩 Features     : /workspaces/tf_btp_info/tfscripts/tests/
🚩 Plan File    : /workspaces/tf_btp_info/tfscripts/mission_3774/step1/plan.out.json

🚩 Running tests. 🎉

/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:38: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  feature.starttime = datetime.utcnow()
Feature: Certain variables should always be defined  # /workspaces/tf_btp_info/tfscripts/tests/naming_standards.feature
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:44: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  scenario.starttime = datetime.utcnow()

    Scenario Outline: Naming Standard on all available variables
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:50: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  step.starttime = datetime.utcnow()
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:68: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  step.endtime = datetime.utcnow()
        Given I have not defined variable foo or moo
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:50: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  step.starttime = datetime.utcnow()
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:68: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  step.endtime = datetime.utcnow()
        Then scenario should fail
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:62: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  scenario.endtime = datetime.utcnow()

    Examples:
        |  |
/usr/local/lib/python3.12/site-packages/radish/extensions/time_recorder.py:56: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  feature.endtime = datetime.utcnow()

1 features (1 passed)
0 scenarios (0 passed)
0 steps (0 passed)

Expected Behavior:

Clean output without deprecation warnings.

Tested Versions:

Additional Context: