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

Unit test stub autogenerator #824

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

swapdewalkar
Copy link
Contributor

@swapdewalkar swapdewalkar commented Apr 15, 2024

Address #74

Changes

  • Added new command create-tests in cli module.
  • Wrote logic for generating testcase of given python file

How I tested this

  • Tested with file test1.py

def pr(b: int, c: int) -> int:
    return b + c

def divide(b: pd.Series, c: pd.Series) -> pd.Series:
    return b/c

OUTPUT: test_test1.py

from pandas.core.series import Series


def test_divide():
    b: Series = Series() #TODO fill in
    c: Series = Series() #TODO fill in
    expected: Series = Series() #TODO fill in
    assert expected == test1.divide()

def test_pr():
    b: int = int() #TODO fill in
    c: int = int() #TODO fill in
    expected: int = int() #TODO fill in
    assert expected == test1.pr()

Notes

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

@zilto zilto assigned zilto and unassigned zilto Apr 15, 2024
@zilto zilto self-requested a review April 15, 2024 20:28
@swapdewalkar swapdewalkar changed the title WIP: Unit test stub autogenerator Unit test stub autogenerator Apr 17, 2024
@skrawcz
Copy link
Collaborator

skrawcz commented Apr 22, 2024

@swapdewalkar thanks for this. Been a little busy so I haven't tested this out yet. @zilto if you have time mind taking it for a spin?

@zilto
Copy link
Collaborator

zilto commented Apr 23, 2024

Yes, sorry for the delay, got sick last Wednesday, but starting to feel better. Putting this on my TODO for tomorrow morning!

@zilto
Copy link
Collaborator

zilto commented Apr 23, 2024

Hey @swapdewalkar! I tried running hamilton create-tests locally on a few files from examples/ and always received ModuleNotFoundError. Looking at the code, I think it makes a few assumptions about imports that will be difficult to uphold for CLI usage.

Could you add a minimal example under examples/testgen with a README including the steps you take for the command to work? After I'm able to try the feature, I'll have more feedback on it and the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants