Changeset 2f4cc73 in flex_extract.git for python


Ignore:
Timestamp:
Aug 31, 2018, 2:08:46 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
2ad8ea5
Parents:
dda0e9d
Message:

changed testing from unittest to pytest and adapted existing testcases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/pythontest/TestTools.py

    r067a0c3 r2f4cc73  
    22# -*- coding: utf-8 -*-
    33
    4 import unittest
     4import os
    55import sys
    6 import os
    7 sys.path.append('../python')
     6#import unittest
     7import pytest
     8
     9sys.path.append('../')
     10import _config
    811from tools import init128, to_param_id, my_error, read_ecenv
    912
    1013
    11 class TestTools(unittest.TestCase):
     14class TestTools():
    1215    '''
    1316    '''
     
    1619        pass
    1720
     21    def test_get_cmdline_arguments(self):
     22        assert True
     23
    1824    def test_init128(self):
    1925        '''
    2026        '''
    21         table128 = init128('../grib_templates/ecmwf_grib1_table_128')
     27        table128 = init128(_config.PATH_GRIBTABLE)
    2228        expected = {'078': 'TCLW', '130': 'T', '034': 'SST'}
    2329        # check a sample of parameters which must have been read in
    2430        result = all((k in table128 and table128[k]==v) for k,v in expected.iteritems())
    25         self.assertEqual(result, True)
     31        assert result == True
    2632
    2733
     
    2935        '''
    3036        '''
    31         table128 = init128('../grib_templates/ecmwf_grib1_table_128')
     37        table128 = init128(_config.PATH_GRIBTABLE)
    3238        pars = to_param_id("T/SP/LSP/SSHF", table128)
    3339        for par in pars:
    34             self.assertIn(par, [130, 134, 142, 146])
     40            assert par in [130, 134, 142, 146]
    3541
    3642    def test_error_notifcation(self):
    3743        '''
    3844        '''
    39         with self.assertRaises(SystemExit) as re:
     45        with pytest.raises(SystemExit) as pytest_wrapped_e:
    4046            my_error(['${USER}', 'anne.philipp@univie.ac.at'], 'Failed!')
    41         self.assertEqual(re.exception.code, 1)
     47        assert pytest_wrapped_e.type == SystemExit
     48        assert pytest_wrapped_e.value.code == 1
    4249
    4350    def test_read_ecenv(self):
    44 
     51        '''
     52        '''
    4553        envs_ref = {'ECUID': 'km4a',
    4654                    'ECGID': 'at',
     
    5058        envs = read_ecenv(os.getcwd() + '/TestData/ECMWF_ENV')
    5159
    52         self.assertDictEqual(envs_ref, envs)
     60        assert envs_ref == envs
    5361
    5462
     63    def test_clean_up(self):
     64        assert True
     65
     66    def test_normal_exit(self):
     67        assert True
     68
     69    def test_product(self):
     70        assert True
     71
     72    def test_silent_remove(self):
     73        assert True
    5574
    5675
     76    def test_get_list_as_string(self):
     77        assert True
     78
     79    def test_make_dir(self):
     80        assert True
     81
     82    def test_put_file_to_ecserver(self):
     83        assert True
     84
     85    def submit_job_to_ecserver(self):
     86        assert True
    5787
    5888if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG