-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Resolve #870] Bugfix in _call_sceptre_handler #871
[Resolve #870] Bugfix in _call_sceptre_handler #871
Conversation
Could you add a regression test that breaks without this PR? |
@nabeelamjad , I have spent 1.5 hours or so on it and I still can't figure out a way to test my change or get my head around those tests. I tried copying the VPC test and adding an os.chdir call in the sceptre handler and that unfortunately breaks many tests. Any suggestions? |
Perhaps something like this? def test_body_with_chdir_template(self):
self.template.sceptre_user_data = None
self.template.name = "chdir"
current_dir = os.getcwd()
self.template.path = os.path.join(
os.getcwd(),
"tests/fixtures/templates/chdir.py"
)
try:
json.loads(self.template.body)
except ValueError:
assert False
finally:
os.chdir(current_dir) Your # -*- coding: utf-8 -*-
from troposphere import Template
from os import chdir
def sceptre_handler(sceptre_user_data):
t = Template()
chdir("..")
return t.to_json() I think the issue you're facing is that since you change directory and the tests are using Alternatively you could use something like this at the top (before the @pytest.fixture(autouse=True)
def run_before_each():
current_dir = os.getcwd()
yield
os.chdir(current_dir) |
3926013
to
5be4d13
Compare
@nabeelamjad thanks, that worked perfectly and makes sense. I've updated the PR with the passing tests and confirmed they reproduced the original issue without the bugfix. |
Before this, the _call_sceptre_handler method makes multiple calls to os.getcwd() in determining paths to add and then later paths to remove. In the event that the sceptre_handler code then makes a call to os.chdir, the second call ends up removing the wrong path. This patch ensures that the paths removed are the same ones that are added.
5be4d13
to
1e718ee
Compare
@nabeelamjad , also is there chance I can get my bugfix released after it's merged? |
@alexharv074 I don't have the authority to merge/release. @ngfgrant handles those. From my end the PR looks good, no issues and a good catch 👍 |
@ngfgrant , I saw a comment saying something about linting not passing but I can't find that comment. Was it deleted? AFAICT, linting is fine:
Is there anything else? |
Hey @alexharv074 i didn’t see a comment about lint. What happens when you ‘make lint’ locally? |
@ngfgrant , nevermind I saw something about it in my email but make lint tests pass locally in the pipeline so I can't see any lint issue. |
Before this, the _call_sceptre_handler method makes multiple calls to os.getcwd() in determining paths to add and then later paths to remove. In the event that the sceptre_handler code then makes a call to os.chdir, the second call ends up removing the wrong path. This patch ensures that the paths removed are the same ones that are added.
Before this, the _call_sceptre_handler method makes multiple calls to
os.getcwd() in determining paths to add and then later paths to remove.
In the event that the sceptre_handler code then makes a call to
os.chdir, the second call ends up removing the wrong path.
This patch ensures that the paths removed are the same ones that are
added.
PR Checklist
[Resolve #issue-number]
.make test
) are passing.make lint
) checks.and description in grammatically correct, complete sentences.
Approver/Reviewer Checklist
Other Information
Guide to writing a good commit