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

Enhance set method and add get_name utility function #34

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Conversation

onuratakan
Copy link
Member

Introduce an optional code parameter to the set method and implement a get_name utility function to retrieve the name of various types of values.

Copy link

benchify bot commented Nov 26, 2024

🧪 Benchify Analysis of PR 34

The property-based tests for the upsonic/remote/on_prem.py file revealed a potential issue.

One test, which checked that dumping local files creates files in the upsonic subdirectory with the expected content, encountered an unexpected exception 38 times out of an unspecified number of test runs. This may indicate a problem with handling certain types of input.

However, two other tests passed successfully: one that checked if extracting source code from an object returns a valid string representation, and another that checked if extracting needed libraries from a function maps variable names to their correct module names.

To further investigate the issue, it would be helpful to examine the specific input that caused the exception and the error message that was raised. This could provide more insight into the cause of the problem and guide the process of fixing it.

File Example Input # Inputs Found Description
💥 upsonic/remote/on_prem.py extract={'§\x8d\x00': ''} 38 An unexpected exception occurred while testing that dumping local files creates files in the upsonic subdirectory with the expected content.
upsonic/remote/on_prem.py obj=95, key='' 100 When extracting source code from an object, it returns a valid string representation
upsonic/remote/on_prem.py x=39, debug=True 100 When extracting needed libraries from a function, each variable name maps to its correct module name
Reproducible Unit Tests
import jsonpickle
import unittest
import time


from upsonic.remote.on_prem import *
# Property: When dumping local files, the files are created in the upsonic subdirectory with the expected content
def benchify_test_dump_local_files_creates_expected_files(extract):
    temp_dir = "test_dir"
    os.makedirs(temp_dir, exist_ok=True)
    try:
        dump_local_files(extract, local_directory=temp_dir)
        for fname, content in extract.items():
            expected_path = os.path.join(temp_dir, "upsonic", fname)
            assert os.path.exists(expected_path)
            with open(expected_path) as f:
                assert f.read() == content
    finally:
        shutil.rmtree(temp_dir)


# The next batch of tests throw unexpected exceptions.
def test_dump_local_files_creates_expected_files_exception_0():
    extract={'\x00': ''}
    benchify_test_dump_local_files_creates_expected_files(extract)

def test_dump_local_files_creates_expected_files_exception_1():
    extract={\x00': ''}
    benchify_test_dump_local_files_creates_expected_files(extract)

def test_dump_local_files_creates_expected_files_exception_2():
    extract={\x8d\x00': ''}
    benchify_test_dump_local_files_creates_expected_files(extract)

# Found 35 more tests that throw unexpected exceptions.



# The next batch of tests are passing.
def test_dump_local_files_creates_expected_files_passing_0():
    extract={}
    benchify_test_dump_local_files_creates_expected_files(extract)

def test_dump_local_files_creates_expected_files_passing_1():
    extract={'0': ''}
    benchify_test_dump_local_files_creates_expected_files(extract)

def test_dump_local_files_creates_expected_files_passing_2():
    extract={'º': ''}
    benchify_test_dump_local_files_creates_expected_files(extract)

# Found 41 more passing tests.
# Property: When extracting source code from an object, it returns a valid string representation

def benchify_test_extract_source_returns_string(obj, key):
    source = extract_source(obj, key)
    assert isinstance(source, str)


# The next batch of tests are passing.
def test_extract_source_returns_string_passing_0():
    obj=0
    key=''
    benchify_test_extract_source_returns_string(obj, key)

def test_extract_source_returns_string_passing_1():
    obj=9
    key=''
    benchify_test_extract_source_returns_string(obj, key)

def test_extract_source_returns_string_passing_2():
    obj=1
    key=''
    benchify_test_extract_source_returns_string(obj, key)

# Found 97 more passing tests.# Property: When extracting needed libraries from a function, each variable name maps to its correct module name

def benchify_test_extract_needed_libraries_maps_vars_to_modules(x, debug):
    def f(): return x
    result = extract_needed_libraries(f, debug)
    assert result == {}


# The next batch of tests are passing.
def test_extract_needed_libraries_maps_vars_to_modules_passing_0():
    x=0
    debug=True
    benchify_test_extract_needed_libraries_maps_vars_to_modules(x, debug)

def test_extract_needed_libraries_maps_vars_to_modules_passing_1():
    x=0
    debug=False
    benchify_test_extract_needed_libraries_maps_vars_to_modules(x, debug)

def test_extract_needed_libraries_maps_vars_to_modules_passing_2():
    x=82
    debug=True
    benchify_test_extract_needed_libraries_maps_vars_to_modules(x, debug)

# Found 97 more passing tests.

@onuratakan onuratakan merged commit 93b9d84 into master Nov 26, 2024
2 checks passed
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.

1 participant