Skip to content

[REFACTOR] moving test data to JSON #663

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

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .cruch_bruteforce import arrayManipulation

FILE_PATH = str(Path(__file__).resolve().parent)

CRUCH_SMALL_TEST_CASES = load_test_cases(
CRUCH_SMALL_TEST_CASES = loadTestCases(
FILE_PATH + '/cruch.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .cruch_optimized import arrayManipulation

FILE_PATH = str(Path(__file__).resolve().parent)

CRUCH_SMALL_TEST_CASES = load_test_cases(
CRUCH_SMALL_TEST_CASES = loadTestCases(
FILE_PATH + '/cruch.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .ctci_array_left_rotation import rotLeft, rotLeftOne

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/ctci_array_left_rotation.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .minimum_swaps_2 import minimumSwaps

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/minimum_swaps_2.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .new_year_chaos import minimumBribes, minimumBribesText

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/new_year_chaos.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .two_d_array import hourglassSum

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/two_d_array.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .count_triplets_1 import countTriplets, countTripletsBruteForce

FILE_PATH = str(Path(__file__).resolve().parent)

SMALL_TEST_CASES = load_test_cases(
SMALL_TEST_CASES = loadTestCases(
FILE_PATH + '/count_triplets_1.small.testcases.json')

TEST_CASES_BIG = load_test_cases(
TEST_CASES_BIG = loadTestCases(
FILE_PATH + '/count_triplets_1.big.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .ctci_ransom_note import checkMagazine, checkMagazineText

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/ctci_ransom_note.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .frequency_queries import freqQuery

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/frequency_queries.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import unittest
import json
from pathlib import Path

from ....lib.loader import loadTestCases
from .sherlock_and_anagrams import sherlockAndAnagrams

FILE_PATH = str(Path(__file__).resolve().parent)
JSON_DATA_FILE = FILE_PATH + '/sherlock_and_anagrams.json'
with open(JSON_DATA_FILE, encoding="utf-8") as file:
TEST_CASES = json.load(file)

TEST_CASES = loadTestCases(
FILE_PATH + '/sherlock_and_anagrams.testcases.json')


class TestSherlockAndAnagrams(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .two_strings import twoStrings

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/two_strings.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .max_array_sum import maxSubsetSum

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/max_array_sum.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .roads_and_libraries import roadsAndLibraries

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/roads_and_libraries.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .angry_children import maxMin

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/angry_children.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .greedy_florist import getMinimumCost

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/greedy_florist.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .luck_balance import luckBalance

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/luck_balance.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .minimum_absolute_difference_in_an_array import minimumAbsoluteDifference

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/minimum_absolute_difference_in_an_array.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .flipping_bits import flippingBits

FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/flipping_bits.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import unittest
from pathlib import Path

from ....hackerrank.lib.loader import load_test_cases
from ....lib.loader import loadTestCases
from .friend_circle_queries import maxCircle


FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = load_test_cases(
TEST_CASES = loadTestCases(
FILE_PATH + '/friend_circle_queries.testcases.json')


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"title": "Sample Test case 0",
"input": 5,
"expected": 5
},
{
"title": "Sample Test case 1",
"input": 12,
"expected": 144
},
{
"title": "Sample Test case 2",
"input": 17,
"expected": 1597
}
]
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import unittest
from pathlib import Path

from ....lib.loader import loadTestCases
from .ctci_fibonacci_numbers import fibonacci

TEST_CASES = [
{
'title': 'Sample Test case 0',
'input': 5,
'answer': 5
},
{
'title': 'Sample Test case 1',
'input': 12,
'answer': 144,
},
{
'title': 'Sample Test case 2',
'input': 17,
'answer': 1597
}
]
FILE_PATH = str(Path(__file__).resolve().parent)

TEST_CASES = loadTestCases(
FILE_PATH + '/ctci_fibonacci_numbers.testcases.json')


class TestRecursionFibonacciNumbers(unittest.TestCase):
Expand All @@ -27,6 +17,6 @@ def test_fibonacci(self):
for _, _tt in enumerate(TEST_CASES):

self.assertEqual(
fibonacci(_tt['input']), _tt['answer'],
fibonacci(_tt['input']), _tt['expected'],
f"{_} | fibonacci({_tt['input']}) must be "
f"=> {_tt['answer']} in {_tt['title']}")
f"=> {_tt['expected']} in {_tt['title']}")
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import unittest
import json
from pathlib import Path
from typing import Dict

from ....lib.loader import loadTestCases
from .ctci_recursive_staircase import stepPerms, stepPermsComputWithCache
from .ctci_recursive_staircase_alternative import stepPerms as stepPermsAlt

FILE_PATH = str(Path(__file__).resolve().parent)

with open(
FILE_PATH + '/ctci_recursive_staircase.testcases.json',
encoding="utf-8"
) as file1:
TEST_CASES = json.load(file1)

with open(
FILE_PATH + '/ctci_recursive_staircase_generalized.testcases.json',
encoding="utf-8"
) as file2:
TEST_CASES_GENERALIZED = json.load(file2)
TEST_CASES = loadTestCases(
FILE_PATH + '/ctci_recursive_staircase.testcases.json')

TEST_CASES_GENERALIZED = loadTestCases(
FILE_PATH + '/ctci_recursive_staircase_generalized.testcases.json')


class TestStaircase(unittest.TestCase):
Expand Down
Loading
Loading