Пример #1
0
    os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))

# Import tester
from tester import failtest, passtest, assertequals, runcmd, preparefile, runcmdsafe
#############    END UNTOUCHABLE CODE   #############
#####################################################

###################################
# Write your testing script below #
###################################

# prepare files
preparefile('./test.rkt')
# run test
python_bin = sys.executable
b_stdout, b_stderr, b_exitcode = runcmdsafe(f'racket ./test.rkt')

# Convert stdout bytes to utf-8
stdout = ""
stderr = ""
try:
    stdout = b_stdout.decode('utf-8')
    stderr = b_stderr.decode('utf-8')
except:
    pass

# Comparison with answer and output here
try:
    with open('answer', 'r') as file1, open('output', 'r') as file2:
        answer = str(file1.read())
        output = str(file2.read())
Пример #2
0
# Import tester
from tester import failtest, passtest, assertequals, runcmd, preparefile, runcmdsafe
#############    END UNTOUCHABLE CODE   #############
#####################################################

###################################
# Write your testing script below #
###################################
import pickle

# prepare files
preparefile('./test.py')

# run test
python_bin = sys.executable
b_stdout, b_stderr, b_exitcode = runcmdsafe(f'{python_bin} ./test.py')

# Convert stdout bytes to utf-8
stdout = ""
stderr = ""
try:
    stdout = b_stdout.decode('utf-8')
    stderr = b_stderr.decode('utf-8')
except:
    pass

# With pickle, you can keep your raw data intact via serialization.
# In this example, two frozensets with different orders will
# still be equal with the use of serialization.
try:
    with open('answer', 'rb') as file1, open('output', 'rb') as file2:
Пример #3
0
# Import tester
from tester import failtest, passtest, assertequals, runcmd, preparefile, runcmdsafe
#############    END UNTOUCHABLE CODE   #############
#####################################################

###################################
# Write your testing script below #
###################################
python_bin = sys.executable
import pickle

# prepare necessary files
preparefile('./test.rkt')

# run test file
runcmdsafe('rm ./output')
b_stdout, b_stderr, b_exitcode = runcmdsafe(f'racket ./test.rkt')

# convert stdout bytes to utf-8
stdout = ""
stderr = ""
try:
    stdout = b_stdout.decode('utf-8')
    stderr = b_stderr.decode('utf-8')
except:
    pass

# stdout comparison with expected.txt here
try:
    with open('answer', 'rb') as file1, open('output', 'rb') as file2:
        answer = str(file1.read()).strip()
Пример #4
0
# Import tester
from tester import failtest, passtest, assertequals, runcmd, preparefile, runcmdsafe
#############    END UNTOUCHABLE CODE   #############
#####################################################

###################################
# Write your testing script below #
###################################
import pickle, shutil

# prepare files
preparefile('./test.java')

# run test
runcmdsafe('javac -d ./ test.java ../../Counter.java')
b_stdout, b_stderr, b_exitcode = runcmdsafe('java p0.Test')

# Convert stdout bytes to utf-8
stdout = ""
stderr = ""
try:
    stdout = b_stdout.decode('utf-8')
    stderr = b_stderr.decode('utf-8')
except:
    pass

try:
    with open('answer', 'r') as file1, open('output', 'r') as file2:
        answer = str(file1.read())
        output = str(file2.read())
Пример #5
0
from tester import failtest, passtest, assertequals, runcmd, preparefile, runcmdsafe
#############    END UNTOUCHABLE CODE   #############
#####################################################

###################################
# Write your testing script below #
###################################

# prepare necessary files
preparefile('./Cargo.toml')
preparefile('./Cargo.lock')
preparefile('./src')
preparefile('./src/main.rs')

# run test file
b_stdout, b_stderr, b_exitcode = runcmdsafe(f'cargo run')

# convert stdout bytes to utf-8
stdout = ""
stderr = ""
try:
    stdout = b_stdout.decode('utf-8')
    stderr = b_stderr.decode('utf-8')
except:
    pass

try:
    with open('answer', 'r') as file1, open('output', 'r') as file2:
        answer = file1.read()
        output = file2.read()
        file1.close()
Пример #6
0
#####################################################

###################################
# Write your testing script below #
###################################
python_bin = sys.executable
import pickle

# prepare necessary files
preparefile('./Cargo.toml')
preparefile('./Cargo.lock')
preparefile('./src')
preparefile('./src/main.rs')

# run test file
b_stdout, b_stderr, b_exitcode = runcmdsafe(f'cargo run')


# convert stdout bytes to utf-8
stdout = ""
stderr = ""
try:
	stdout = b_stdout.decode('utf-8')
	stderr = b_stderr.decode('utf-8')
except:
	pass

try:
	with open('answer', 'rb') as file1, open('output', 'rb') as file2:
		answer = pickle.load(file1)
		output = pickle.load(file2)