def test_AssertToChaiExpectProcess_05(self):
     src = """
         def test_func1( self ):
             assert aval > 100
     """
     nodes = parseSource(src)
     cvtr = AssertToChaiExpectConverter()
     matches = cvtr.gather(nodes)
     cvtr.processOne(matches[0])
     # dumpNodes( nodes )
     assert nodesToLines(nodes) == [
         "def test_func1( self ):",
         "    expect( aval > 100 ).to.be.ok",
     ]
 def test_AssertToChaiExpectProcess_02(self):
     src = """
         def test_func1( self ):
             assert aval != 'bim'
     """
     nodes = parseSource(src)
     cvtr = AssertToChaiExpectConverter()
     matches = cvtr.gather(nodes)
     cvtr.processOne(matches[0])
     # dumpNodes( nodes )
     assert nodesToLines(nodes) == [
         "def test_func1( self ):",
         "    expect( aval ).not.to.eql( 'bim' )",
     ]
 def test_AssertToChaiExpectGather_02(self):
     src = """
         def test_func1( self ):
             assert aval != 'bim'
     """
     nodes = parseSource(src)
     match = AssertToChaiExpectConverter().gather(nodes)[0]
     assert match.node.toString() == "assert aval != 'bim'"
     assert match.comp_op.toString() == "!="
     assert "truthy" not in match
 def test_AssertToChaiExpectGather_03(self):
     src = """
         def test_func1( self ):
             assert aval
     """
     nodes = parseSource(src)
     match = AssertToChaiExpectConverter().gather(nodes)[0]
     assert match.node.toString() == "assert aval"
     assert match.truthy.toString() == "aval"
     assert "comp_op" not in match
def processTestModule(module_nodes):

    infos = AnonObj(class_names=[], func_names=[])

    # convert asserts before anything else
    assert_cvtr = AssertToChaiExpectConverter()
    assert_cvtr.processAll(assert_cvtr.gather(module_nodes))

    ConverterChain([ImportNameConverter,
                    ImportFromConverter]).convertAll(module_nodes)

    class_gath = UnittestClassToMochaDescribeConverter("unittest.TestCase")
    class_matches = class_gath.gather(module_nodes)

    if not class_matches:
        print("NO CLASSES")
    else:
        for class_match in class_matches:
            print("\nCLASS", class_match.name)
            class_gath.processOne(class_match)
            fixComments(class_match.suite)

            func_matches = PytestMethodToMochaItConverter(
                in_class=True).gather(class_match.suite)
            for func_match in func_matches:
                print("----METHOD", func_match.name)
                processTestFunction(func_match.node, in_class=True)
            infos.class_names.append(class_match.name.toString())

    func_matches = PytestMethodToMochaItConverter().gather(module_nodes)
    for func_match in func_matches:
        print("FUNCTION ", func_match.name)
        processTestFunction(func_match.node)
        infos.func_names.append(func_match.name.toString())

    fixComments(module_nodes)
    fixPassStatements(module_nodes)
    fixSimpleRenames(module_nodes)

    fixSemicolons(module_nodes)

    return infos
 def test_AssertToChaiExpectProcess_06(self):
     src = """
     class Tests( unittest.TestCase ):
         def test_getAttr( self ):
             try:
                 getattr( obj, 'bom' )
             except:
                 excepted = True
             assert excepted
     """
     nodes = parseSource(src)
     cvtr = AssertToChaiExpectConverter()
     matches = cvtr.gather(nodes)
     cvtr.processOne(matches[0])
     # dumpNodes( nodes )
     assert nodesToLines(nodes) == [
         "class Tests( unittest.TestCase ):",
         "    def test_getAttr( self ):",
         "        try:",
         "            getattr( obj, 'bom' )",
         "        except:",
         "            excepted = True",
         "        expect( excepted ).to.be.ok",
     ]