Esempio n. 1
0
# Test cases for various fread parse scenarios. These tests are expected to be
# fairly small and straightforward.
#-------------------------------------------------------------------------------
import datatable as dt
from datatable import ltype, stype
import math
import os
import pytest
import random
import re
import time
from datatable.internal import frame_integrity_check
from tests import random_string, list_equals, assert_equals, get_core_tests


@pytest.mark.parametrize("testname", get_core_tests("fread"), indirect=True)
def test_core_fread(testname):
    # Run all core tests in suite "fread"
    dt.lib.core.run_test("fread", testname)


#-------------------------------------------------------------------------------
# Test parsing of various field types
#-------------------------------------------------------------------------------


def test_bool1():
    d0 = dt.fread("L,T,U,D\n"
                  "true,True,TRUE,1\n"
                  "false,False,FALSE,0\n"
                  ",,,\n")
Esempio n. 2
0
def test_collections():
    DT = dt.Frame()
    if sys.version_info >= (3, 7):
        import collections.abc
        assert isinstance(DT, collections.abc.Sized)
        assert isinstance(DT, collections.abc.Iterable)
        assert isinstance(DT, collections.abc.Reversible)
    else:
        import collections
        assert isinstance(DT, collections.Sized)
        assert isinstance(DT, collections.Iterable)
        assert isinstance(DT, collections.Reversible)


@pytest.mark.parametrize("testname", get_core_tests("coverage"), indirect=True)
def test_core_coverage(testname):
    # Run all core tests in suite "coverage"
    core.run_test("coverage", testname)


#-------------------------------------------------------------------------------
# Run several random attacks on a datatable as a whole
#-------------------------------------------------------------------------------


# To pick up attacks based on the corresponding weights, random attacker
# uses random.choices(), introduced in Python 3.6.
@pytest.mark.usefixtures("numpy")
def test_random_attack():
    import subprocess
Esempio n. 3
0
#-------------------------------------------------------------------------------
import datatable as dt
import itertools
import pytest
import subprocess
import sys
import time
from datatable.lib import core
from tests import (cpp_test, skip_on_jenkins, get_core_tests)

#-------------------------------------------------------------------------------
# "parallel" tests
#-------------------------------------------------------------------------------


@pytest.mark.parametrize("testname", get_core_tests("parallel"), indirect=True)
def test_core_parallel(testname):
    # Run all core tests in suite "parallel"
    core.run_test("parallel", testname)


def test_multiprocessing_threadpool():
    # Verify that threads work properly after forking (#1758)
    import multiprocessing as mp
    from datatable.internal import get_thread_ids
    parent_threads = get_thread_ids()
    n = 4
    with mp.Pool(processes=n) as pool:
        child_threads = pool.starmap(get_thread_ids, [()] * n, chunksize=1)
        assert len(child_threads) == n
        for chthreads in child_threads: