# -*- coding: utf-8 -*-
import os
import unittest

from pyaxiom.netcdf import CFDataset
from pyaxiom.utils import all_subclasses
from pyaxiom.netcdf.sensors.dsg import *

import logging
from pyaxiom import logger
logger.level = logging.DEBUG
logger.handlers = [logging.StreamHandler()]


class TestIsMine(unittest.TestCase):

    def test_is_mine(self):

        tests = {
            OrthogonalMultidimensionalProfile: [
                os.path.join(os.path.dirname(__file__), 'profile', 'resources', 'om-single.nc'),
                os.path.join(os.path.dirname(__file__), 'profile', 'resources', 'om-multiple.nc')
            ],
            IncompleteMultidimensionalProfile: [
                os.path.join(os.path.dirname(__file__), 'profile', 'resources', 'im-multiple.nc')
            ],
            IncompleteMultidimensionalTrajectory: [
                os.path.join(os.path.dirname(__file__), 'trajectory', 'resources', 'im-single.nc'),
                os.path.join(os.path.dirname(__file__), 'trajectory', 'resources', 'im-multiple.nc')
            ]
        }

        allsubs = list(all_subclasses(CFDataset))
        for klass, file_list in tests.items():
            subs = [ s for s in allsubs if s != klass ]
            for fp in file_list:
                dsg = CFDataset(fp)
                logger.info('Testing {} - {}...'.format(klass.__name__, fp))
                assert klass.is_mine(dsg) is True
                with self.subTest(msg='{} - {}'.format(klass.__name__, fp), dsg=dsg, klass=klass):
                    for s in subs:
                        if hasattr(s, 'is_mine'):
                            logger.info('  * Trying {}...'.format(s.__name__))
                            assert s.is_mine(dsg) is False

@@ -31,19 +31,18 @@
  os%0A
+%0A
 import 
-unit
+py
 test
@@ -284,105 +284,52 @@
 %5D%0A%0A%0A
-class TestIsMine(unittest.TestCase):%0A%0A    def test_is_mine(self):%0A%0A        tests = %7B%0A            
+@pytest.mark.parametrize(%22klass,fp%22, %5B%0A    (
 Orth
@@ -353,35 +353,25 @@
 ionalProfile
-: %5B%0A       
+,
          os.
@@ -442,33 +442,66 @@
 -single.nc')
+)
 ,%0A    
-   
+(OrthogonalMultidimensionalProfile,
          os.
@@ -582,36 +582,16 @@
 nc')
-%0A            %5D,%0A            
+),%0A    (
 Inco
@@ -619,27 +619,17 @@
 lProfile
-: %5B%0A       
+,
         
@@ -714,36 +714,16 @@
 nc')
-%0A            %5D
+)
 ,%0A    
- 
-       
+(
 Inco
@@ -758,22 +758,9 @@
 tory
-: %5B%0A          
+,
     
@@ -847,20 +847,53 @@
 nc')
+)
 ,%0A    
-      
+(IncompleteMultidimensionalTrajectory,
     
@@ -982,38 +982,43 @@
 nc')
-%0A            %5D%0A        %7D%0A%0A    
+),%0A%5D)%0Adef test_is_mine(klass, fp):%0A
     
@@ -1063,63 +1063,8 @@
 t))%0A
-        for klass, file_list in tests.items():%0A        
     
@@ -1111,53 +1111,8 @@
 s %5D%0A
-            for fp in file_list:%0A            
     
@@ -1131,28 +1131,16 @@
 set(fp)%0A
-            
     logg
@@ -1148,16 +1148,18 @@
 r.info('
+%5Cn
 Testing 
@@ -1164,16 +1164,8 @@
 g %7B%7D
- - %7B%7D...
 '.fo
@@ -1187,27 +1187,11 @@
 me__
-, fp
 ))%0A
-            
     
@@ -1228,123 +1228,8 @@
 rue%0A
-                with self.subTest(msg='%7B%7D - %7B%7D'.format(klass.__name__, fp), dsg=dsg, klass=klass):%0A                
     
@@ -1243,32 +1243,16 @@
 n subs:%0A
-                
         
@@ -1277,32 +1277,16 @@
 mine'):%0A
-                
         
@@ -1340,32 +1340,16 @@
 ame__))%0A
-                
         

Use py.test parametize rather that subTest which is only Py>=3.4