from os import path
from indra.tools.reading.read_files import read_files, get_readers

from nose.plugins.attrib import attr


@attr('slow', 'nonpublic')
def test_read_files():
    "Test that the system can read files."
    # Create the test files.
    example_files = []

    # Get txt content
    abstract_txt = ("This is a paper that contains the phrase: MEK "
                    "phosphorylates ERK.")
    with open('test_abstract.txt', 'w') as f:
        f.write(abstract_txt)
    example_files.append('test_abstract.txt')

    # Get nxml content
    pmc_test_fpath = path.join(path.dirname(path.abspath(__file__)),
                               'pmc_cont_example.nxml')
    if path.exists(pmc_test_fpath):
        example_files.append(pmc_test_fpath)

    assert len(example_files), "No content available to test."

    # Now read them.
    readers = get_readers()
    outputs = read_files(example_files, readers)
    N_out = len(outputs)
    N_exp = 2*len(example_files)
    assert N_out == N_exp, "Expected %d outputs, got %d." % (N_exp, N_out)

@@ -78,16 +78,23 @@
 t_reader
+_classe
 s%0A%0Afrom 
@@ -126,16 +126,69 @@
 t attr%0A%0A
+from indra.tools.reading.readers import EmptyReader%0A%0A
 %0A@attr('
@@ -205,16 +205,28 @@
 npublic'
+, 'notravis'
 )%0Adef te
@@ -920,16 +920,23 @@
   reader
+_classe
 s = get_
@@ -945,16 +945,23 @@
 ader
+_classe
 s()%0A    
 outp
@@ -960,91 +960,261 @@
     
-outputs = read_files(example_files, readers)%0A    N_out = len(outputs)%0A    N_exp = 2
+readers = %5B%5D%0A    for rc in reader_classes:%0A        readers.append(rc())%0A    outputs = read_files(example_files, readers)%0A    N_out = len(outputs)%0A    proper_readers = %5Br for r in readers if not isinstance(r, EmptyReader)%5D%0A    N_exp = len(proper_readers)
 *len

Fix the reading files test.