0

I am newbie in test case data mocking in python, Ask is to mock 2 github files for our test cases and I am using pyGithub.ContentFile.ContentFile class to do that but the problem occurs as soon as I mock the 2nd file it overwrite the first one instance as well.

Below are the 2 function which mock the 2 file

def first_file():
    """
    Returns the contents of the first file found in the git repo
    using mocked data
    """
    values = b"""
this is a test file one
    """
    contents = ContentFile.ContentFile
    contents.path = "first.txt"
    contents.decoded_content = values
    contents.sha = "mock_sha"
    return contents

def second_file():
    """
    Returns the contents of the second file found in the git repo
    using mocked data
    """
    values = b"""
this is a test file two which holds data more than first one
    """
    contents = ContentFile.ContentFile
    contents.path = "second.txt"
    contents.decoded_content = values
    contents.sha = "mock_sha"
    return contents

But when mocking, both files have the second_file data which I assume due to class ContentFile.ContentFile. I need to create object for this class to have 2 instance but here I am getting baffled with object instantiation, Any suggestions would be great help ?

class ContentFile(requester: Requester, headers: Dict[str, Union[str, int]], attributes: Dict[str, Any], completed: bool)
Atul Singh
  • 59
  • 1
  • 9

0 Answers0