Skip to content
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

fix: test catch if function is empty #54597

Merged
merged 3 commits into from May 7, 2024

Conversation

ilenia-magoni
Copy link
Contributor

Checklist:

Closes #54596

@github-actions github-actions bot added the scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. label May 1, 2024
Copy link
Contributor

@Dario-DC Dario-DC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Dario-DC Dario-DC enabled auto-merge (squash) May 1, 2024 20:21
@Dario-DC Dario-DC added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label May 2, 2024
@zairahira zairahira self-assigned this May 6, 2024
Copy link
Member

@zairahira zairahira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code still passes if variables are present outside:

import secrets
import string

# Define the possible characters for the password
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation

# Combine all characters
all_characters = letters + digits + symbols

def generate_password():  
    # Define the possible characters for the password
    letters = string.ascii_letters
    digits = string.digits
    symbols = string.punctuation

    # Combine all characters
    all_characters = letters + digits + symbols

Here is the hint and test to fix this:

The four variable declarations shouldn't exist outside the function.

```js
({
  test: () => assert.isFalse(runPython(`
  
  _Node(_code).find_variable('letters').is_equivalent('letters = string.ascii_letters') and \\
  _Node(_code).find_variable('digits').is_equivalent('digits = string.digits') and \\
  _Node(_code).find_variable('symbols').is_equivalent('symbols = string.punctuation') and \\
  _Node(_code).find_variable('all_characters').is_equivalent('all_characters = letters + digits + symbols')
  `))
})
```

@ilenia-magoni
Copy link
Contributor Author

ilenia-magoni commented May 6, 2024

Yes, I am checking that the new function is defined correctly, which was the issue, not if the are extra pieces of code @zairahira

also that test wouldn't work if you want to check that all the variables are not present, it needs to be with or

@Dario-DC Dario-DC requested a review from zairahira May 6, 2024 16:26
Copy link
Member

@zairahira zairahira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👍️

@Dario-DC Dario-DC merged commit dea3598 into freeCodeCamp:main May 7, 2024
22 checks passed
@ilenia-magoni ilenia-magoni deleted the ilenia-magoni/issue54596 branch May 7, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new python course scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test in step 13 of Password Generator project not checking for function body content
3 participants