question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@mock_cloudformation doesn't work

See original GitHub issue

requirements.txt

moto
pyyaml
openapi-spec-validator

hello.py

from moto import mock_cloudformation

import unittest

@mock_cloudformation
class HelloTest(unittest.TestCase):

    def test_hello(self):
        self.assertEqual(2, 2)
    
if __name__=="__main__":
    unittest.main()

run

(env) me@mine % python hello.py                             
Traceback (most recent call last):
  File "hello.py", line 6, in <module>
    class HelloTest(unittest.TestCase):
  File "/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/moto/__init__.py", line 8, in f
    module = importlib.import_module(module_name, "moto")
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/moto/cloudformation/__init__.py", line 1, in <module>
    from .models import cloudformation_backends
  File "/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/moto/cloudformation/models.py", line 18, in <module>
    from .parsing import ResourceMap, OutputMap
  File "/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 17, in <module>
    from moto.apigateway import models  # noqa  # pylint: disable=all
  File "/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/moto/apigateway/__init__.py", line 1, in <module>
    from .models import apigateway_backends
  File "/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/moto/apigateway/models.py", line 15, in <module>
    from openapi_spec_validator.exceptions import OpenAPIValidationError
ImportError: cannot import name 'OpenAPIValidationError' from 'openapi_spec_validator.exceptions' (/Users/me/work/gists/aws/moto_cloudformation/env/lib/python3.8/site-packages/openapi_spec_validator/exceptions.py)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
bblommerscommented, Sep 12, 2022

Thanks for raising them @jhw! All three issues should be fixed as of moto >= 4.0.4.dev2

2reactions
bblommerscommented, Sep 11, 2022

Moto 4.0.3 is now available on PyPi! I’ll close this, but please let us know if you run into any other issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting CloudFormation - AWS Documentation
Troubleshoot issues that might occur when you create, update, or delete an AWS CloudFormation stack.
Read more >
Is there a way to use an cloudformation template to mock all ...
Hi Folks, I'd like to use an cloudformation.yaml or json file to mock all supported resources. Is there any way to do it...
Read more >
AWS CloudFormation Doesn't Do That Yet?! No Problem
Update: An Update event is invoked when the custom resource itself has a property that has changed as part of a CloudFormation deploy....
Read more >
Is there a way to unit test AWS Cloudformation template
Here's a breakdown of how several methods of testing software can be applied to CloudFormation templates/stacks: Linting.
Read more >
Two years with CloudFormation: lessons learned
CloudFormation is a great tool for describing your AWS Infrastructure as Code. In this post I went through some of the things I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found