Skip to content

Commit

Permalink
update:ix data
Browse files Browse the repository at this point in the history
  • Loading branch information
terryyz committed May 7, 2024
1 parent 5ec358e commit 735c666
Show file tree
Hide file tree
Showing 10 changed files with 846 additions and 867 deletions.
5 changes: 1 addition & 4 deletions data/clean/f_615_xiaoheng.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ def setUp(self):
f.write("ERROR 11:30:10 This is an error message\n")
f.write("WARNING 11:35:10 This is a warning message\n")

def tearDown(self):
# Cleanup the test directory and all its contents
shutil.rmtree(self.test_dir)

def tearDown(self):
# Cleanup the test log file
os.remove(self.test_file_path)
shutil.rmtree(self.test_dir)

def test_nonexistent_file(self):
with self.assertRaises(FileNotFoundError):
Expand Down
21 changes: 9 additions & 12 deletions data/clean/f_618_xiaoheng.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ def f_618(path_to_append=PATH_TO_APPEND, json_file=JSON_FILE):
from datetime import datetime

# Update this path if needed to point to an actual temporary directory
PATH_TO_TEMP_JSON = tempfile.mktemp(suffix='.json')

class TestCases(unittest.TestCase):
def setUp(self):
# Create a temporary JSON file for tests that rely on the default JSON file
with open(PATH_TO_TEMP_JSON, 'w') as f:
json.dump({'initial_key': 'initial_value'}, f)

def tearDown(self):
# Clean up the temporary JSON file after all tests have run
os.remove(PATH_TO_TEMP_JSON)

class TestCases(unittest.TestCase):

def setUp(self):
# Create temporary JSON files for testing in text mode
self.test_json_file_1 = tempfile.NamedTemporaryFile(mode='w+', delete=False)
Expand All @@ -66,12 +58,17 @@ def setUp(self):
json.dump({'key': 'value'}, self.test_json_file_2)
self.test_json_file_1.close()
self.test_json_file_2.close()
self.tmp_file = tempfile.mktemp(suffix='.json')
with open(self.tmp_file, 'w') as f:
json.dump({'initial_key': 'initial_value'}, f)


def tearDown(self):
# Remove temporary JSON files after testing
os.unlink(self.test_json_file_1.name)
os.unlink(self.test_json_file_2.name)

os.remove(self.tmp_file)

def test_path_append(self):
# Test if the path is correctly appended to sys.path
new_path = '/new/test/path'
Expand All @@ -97,7 +94,7 @@ def test_default_path(self):

def test_default_json(self):
# Test if the default JSON file is correctly updated when no argument is passed
output = f_618(json_file=PATH_TO_TEMP_JSON)
output = f_618(json_file=self.tmp_file)
self.assertIn('last_updated', output)
self.assertIsInstance(datetime.strptime(output['last_updated'], '%Y-%m-%d %H:%M:%S.%f'), datetime)

Expand Down
8 changes: 3 additions & 5 deletions data/clean/f_665_xiaoheng.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ def setUp(self):
for file in self.sample_files:
with open(os.path.join(TEST_FILES_DIR, file), 'w') as f:
f.write("Sample content for " + file)
if os.path.exists(ARCHIVE_DIR):
shutil.rmtree(ARCHIVE_DIR)

def tearDown(self):
# Remove the test directory after tests
shutil.rmtree(TEST_FILES_DIR)

def setUp(self):
# Ensure the archive directory is clean before each test
if os.path.exists(ARCHIVE_DIR):
shutil.rmtree(ARCHIVE_DIR)
shutil.rmtree(ARCHIVE_DIR)

def test_archive_txt_files(self):
# Archive txt files and verify
Expand Down
1,618 changes: 809 additions & 809 deletions data/open-eval.jsonl

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions data/processed/f_615_xiaoheng_wo_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ def setUp(self):
with open(self.test_file_path, 'w') as f:
f.write("ERROR 11:30:10 This is an error message\n")
f.write("WARNING 11:35:10 This is a warning message\n")
def tearDown(self):
# Cleanup the test directory and all its contents
shutil.rmtree(self.test_dir)
def tearDown(self):
# Cleanup the test log file
os.remove(self.test_file_path)
shutil.rmtree(self.test_dir)
def test_nonexistent_file(self):
with self.assertRaises(FileNotFoundError):
f_610("/path/to/nonexistent/file.log", ['ERROR', 'WARNING'])
Expand Down
16 changes: 7 additions & 9 deletions data/processed/f_618_xiaoheng_wo_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ def f_687(path_to_append=PATH_TO_APPEND, json_file=JSON_FILE):
import sys
from datetime import datetime
# Update this path if needed to point to an actual temporary directory
PATH_TO_TEMP_JSON = tempfile.mktemp(suffix='.json')
class TestCases(unittest.TestCase):
def setUp(self):
# Create a temporary JSON file for tests that rely on the default JSON file
with open(PATH_TO_TEMP_JSON, 'w') as f:
json.dump({'initial_key': 'initial_value'}, f)
def tearDown(self):
# Clean up the temporary JSON file after all tests have run
os.remove(PATH_TO_TEMP_JSON)

def setUp(self):
# Create temporary JSON files for testing in text mode
self.test_json_file_1 = tempfile.NamedTemporaryFile(mode='w+', delete=False)
Expand All @@ -60,10 +53,15 @@ def setUp(self):
json.dump({'key': 'value'}, self.test_json_file_2)
self.test_json_file_1.close()
self.test_json_file_2.close()
self.tmp_file = tempfile.mktemp(suffix='.json')
with open(self.tmp_file, 'w') as f:
json.dump({'initial_key': 'initial_value'}, f)
def tearDown(self):
# Remove temporary JSON files after testing
os.unlink(self.test_json_file_1.name)
os.unlink(self.test_json_file_2.name)
os.remove(self.tmp_file)

def test_path_append(self):
# Test if the path is correctly appended to sys.path
new_path = '/new/test/path'
Expand All @@ -85,6 +83,6 @@ def test_default_path(self):
self.assertIn('/path/to/whatever', sys.path)
def test_default_json(self):
# Test if the default JSON file is correctly updated when no argument is passed
output = f_687(json_file=PATH_TO_TEMP_JSON)
output = f_687(json_file=self.tmp_file)
self.assertIn('last_updated', output)
self.assertIsInstance(datetime.strptime(output['last_updated'], '%Y-%m-%d %H:%M:%S.%f'), datetime)
7 changes: 3 additions & 4 deletions data/processed/f_665_xiaoheng_wo_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ def setUp(self):
for file in self.sample_files:
with open(os.path.join(TEST_FILES_DIR, file), 'w') as f:
f.write("Sample content for " + file)
if os.path.exists(ARCHIVE_DIR):
shutil.rmtree(ARCHIVE_DIR)
def tearDown(self):
# Remove the test directory after tests
shutil.rmtree(TEST_FILES_DIR)
def setUp(self):
# Ensure the archive directory is clean before each test
if os.path.exists(ARCHIVE_DIR):
shutil.rmtree(ARCHIVE_DIR)
shutil.rmtree(ARCHIVE_DIR)
def test_archive_txt_files(self):
# Archive txt files and verify
archive_path = f_131(os.path.join(TEST_FILES_DIR, '*.txt'))
Expand Down
5 changes: 1 addition & 4 deletions data/raw/f_615_xiaoheng.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ def setUp(self):
f.write("ERROR 11:30:10 This is an error message\n")
f.write("WARNING 11:35:10 This is a warning message\n")

def tearDown(self):
# Cleanup the test directory and all its contents
shutil.rmtree(self.test_dir)

def tearDown(self):
# Cleanup the test log file
os.remove(self.test_file_path)
shutil.rmtree(self.test_dir)

def test_nonexistent_file(self):
with self.assertRaises(FileNotFoundError):
Expand Down
21 changes: 9 additions & 12 deletions data/raw/f_618_xiaoheng.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ def f_618(path_to_append=PATH_TO_APPEND, json_file=JSON_FILE):
from datetime import datetime

# Update this path if needed to point to an actual temporary directory
PATH_TO_TEMP_JSON = tempfile.mktemp(suffix='.json')

class TestCases(unittest.TestCase):
def setUp(self):
# Create a temporary JSON file for tests that rely on the default JSON file
with open(PATH_TO_TEMP_JSON, 'w') as f:
json.dump({'initial_key': 'initial_value'}, f)

def tearDown(self):
# Clean up the temporary JSON file after all tests have run
os.remove(PATH_TO_TEMP_JSON)

class TestCases(unittest.TestCase):

def setUp(self):
# Create temporary JSON files for testing in text mode
self.test_json_file_1 = tempfile.NamedTemporaryFile(mode='w+', delete=False)
Expand All @@ -66,12 +58,17 @@ def setUp(self):
json.dump({'key': 'value'}, self.test_json_file_2)
self.test_json_file_1.close()
self.test_json_file_2.close()
self.tmp_file = tempfile.mktemp(suffix='.json')
with open(self.tmp_file, 'w') as f:
json.dump({'initial_key': 'initial_value'}, f)


def tearDown(self):
# Remove temporary JSON files after testing
os.unlink(self.test_json_file_1.name)
os.unlink(self.test_json_file_2.name)

os.remove(self.tmp_file)

def test_path_append(self):
# Test if the path is correctly appended to sys.path
new_path = '/new/test/path'
Expand All @@ -97,7 +94,7 @@ def test_default_path(self):

def test_default_json(self):
# Test if the default JSON file is correctly updated when no argument is passed
output = f_618(json_file=PATH_TO_TEMP_JSON)
output = f_618(json_file=self.tmp_file)
self.assertIn('last_updated', output)
self.assertIsInstance(datetime.strptime(output['last_updated'], '%Y-%m-%d %H:%M:%S.%f'), datetime)

Expand Down
8 changes: 3 additions & 5 deletions data/raw/f_665_xiaoheng.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ def setUp(self):
for file in self.sample_files:
with open(os.path.join(TEST_FILES_DIR, file), 'w') as f:
f.write("Sample content for " + file)
if os.path.exists(ARCHIVE_DIR):
shutil.rmtree(ARCHIVE_DIR)

def tearDown(self):
# Remove the test directory after tests
shutil.rmtree(TEST_FILES_DIR)

def setUp(self):
# Ensure the archive directory is clean before each test
if os.path.exists(ARCHIVE_DIR):
shutil.rmtree(ARCHIVE_DIR)
shutil.rmtree(ARCHIVE_DIR)

def test_archive_txt_files(self):
# Archive txt files and verify
Expand Down

0 comments on commit 735c666

Please sign in to comment.