Noora_Aulia_Hidayat/TestPython/testing(eng)/test_bab1_percobaan1.py
2024-12-31 11:29:14 +07:00

37 lines
1.6 KiB
Python

import random
import sys
from pathlib import Path
import numpy as np
import subprocess
import importlib
import codewars_test
import pandas as pd
# Update paths and filename
path_answer = "/content/" # changed
filename = "answer_bab1_percobaan1.py" # changed
# Import the answer module
pc = importlib.import_module(filename[:-3], ".")
cmd = subprocess.run([sys.executable, f"{path_answer}{filename}"], capture_output=True) # changed
@codewars_test.describe("Chapter 1 | Practicum 1")
def fixed_tests():
print("========================================================================")
@codewars_test.it("1. Load Data Testing")
def test_load_data():
# Assuming expected columns are "Customer ID", "Age" and "Total Spent (USD)"
expected_columns = ['Customer ID', 'Age', 'Total Spent (USD)']
codewars_test.assert_equals(list(pc.data_load().columns), expected_columns, "====> The URL of the dataset used is incorrect; the columns in the dataset do not match")
expected_rows = 50
codewars_test.assert_equals(len(pc.data_load()), expected_rows, "====> Recheck the URL used; the number of data in the dataset is different")
# @codewars_test.it("2. Test Print Nilai Fungsi data_load()")
# def test_total_revenue():
# print("========================================================================")
# output_lines = cmd.stdout.decode().splitlines()
# codewars_test.assert_equals(bool(output_lines), True, '====> Error :Tidak Menampilkan nilai fungsi data_load() menggunakan print()')