Yes, this is very helpful.  I thought I saw an example of use elsewhere 
in our tests but it
wasn't entirely clear.

    Kate

On 10/10/13 2:01 PM, Laurence Rowe wrote:
>
> In src/encoded/tests/test_edw_file.py:
>
> > +# test_format_app
> > +
> > +#@pytest.mark.parametrize('test_num', [1, 2])
> > +# resisting parameterization, as test 1 will go much quicker
> > +# w/o loading workbook which isn't needed
> > +
> > +def test_format_app_fileinfo_expanded(testapp):
> > +    # Test extracting EDW-relevant fields from encoded file.json
> > +    # Expanded JSON
> > +
> > +    test_num = 1
> > +    EDW_TEST_FILE = 'format_app_file_in.' + str(test_num) + '.json'
> > +
> > +    # load input
> > +    f = open(EDW_FILE_TEST_DATA_DIR + '/' + EDW_TEST_FILE)
> > +    file_dict = json.load(f)
>
> For loading data in a python package, there's a handy utility in 
> pkg_resources which makes it easy to load data relative to python 
> modules, see: 
> http://pythonhosted.org/distribute/pkg_resources.html#basic-resource-access
>
> Your loading code here would then become:
>
> |from pkg_resources import resource_stream
> file_dict = json.load(resource_stream(__name__, 'data/edw_file/' + EDW_TEST_FILE))
> |
>
> (*name* is the dotted python path of the current module, so 
> 'encoded.tests.test_edw_file' here.)
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/ENCODE-DCC/encoded/pull/19/files#r6900728>.
>