示例#1
0
    def test_get_text_difficult(self):
        conf = Config("""
config = { # first comment
    hello # ond
    #to be
    solution = { # i'm
        expected = ML, TL #lovin'
        } # it
    solution = { # masha
    possible = A, B, C, D #why?
    #to be
    } # pasha
    #or
    #not
} # korova
""")
        self.assertEqual(
            conf.get_text(), """
config = { # first comment
    hello # ond
    #to be
    solution = { # i'm
        expected = ML, TL #lovin'
        # it
    }
    solution = { # masha
        possible = A, B, C, D #why?
        #to be
        # pasha
    }
    #or
    #not
    # korova
}
""")
示例#2
0
    def test_set(self):
        conf = Config("""
conf = {
solution = {
    expected = ML, TL #cmo
    }
solution = {#abc
    possible = OK
    }#avb
solution = {
    input = "peen"
    }
    
}""")
        conf["conf"].delete("solution", 1)
        conf2 = Config("")
        conf2["expected"] = ["ML", "OK"]
        conf["conf"].set("solution", conf2, None, True)
        self.assertEqual(
            conf.get_text(), """
conf = {
    solution = {
        expected = ML, TL #cmo
    }
    solution = {
        input = "peen"
    }
    
    solution = {
        expected = ML, OK
    }
}
""")
示例#3
0
    def test_deleting(self):
        conf = Config("""el1 = a # hi
        el2 = b # hello
        el3 = v
        config = {
            #why
            
            solution = { #it's
                #so
                expected = ML, TL #unexpected
                possible = OK # cute
                el3 = WA # opa c
                
            }#bye
        }#bye""")
        del conf["el2"]
        del conf["el3"]
        del conf["config"]["solution"]
        self.assertEqual(
            conf.get_text(), """el1 = a # hi
# hello
config = {
    #why
    
    #bye
}
""")
示例#4
0
    def test_deleting(self):
        conf = Config(
            """el1 = a # hi
        el2 = b # hello
        el3 = v
        config = {
            #why
            
            solution = { #it's
                #so
                expected = ML, TL #unexpected
                possible = OK # cute
                el3 = WA # opa c
                
            }#bye
        }#bye"""
        )
        del conf["el2"]
        del conf["el3"]
        del conf["config"]["solution"]
        self.assertEqual(
            conf.get_text(),
            """el1 = a # hi
# hello
config = {
    #why
    
    #bye
}
""",
        )
示例#5
0
    def test_set_sol(self):
        conf = Config("""please = 0.1
input = a.in
output = a.out
""")
        conf2 = Config("""expected = ML, TL
possible = OK""")
        conf["solution"] = [
            conf2,
        ]
        self.assertEqual(
            conf.get_text(), """please = 0.1
input = a.in
output = a.out
solution = {
    expected = ML, TL
    possible = OK
}
""")
示例#6
0
    def test_set_solution(self):
        package_config = Config(
            """please_version = 0.1
my_sister = Liza"""
        )
        for basename in range(5):
            config_file = Config("")
            config_file["source"] = "solutions." + str(basename)
            config_file["expected"] = ["OK"]
            config_file["possible"] = ["ML"]
            package_config.set("solution", config_file, None, True)
        self.assertEqual(
            package_config.get_text(),
            """please_version = 0.1
my_sister = Liza
solution = {
    source = solutions.0
    expected = OK
    possible = ML
}
solution = {
    source = solutions.1
    expected = OK
    possible = ML
}
solution = {
    source = solutions.2
    expected = OK
    possible = ML
}
solution = {
    source = solutions.3
    expected = OK
    possible = ML
}
solution = {
    source = solutions.4
    expected = OK
    possible = ML
}
""",
        )
示例#7
0
    def test_get_text_difficult(self):
        conf = Config(
            """
config = { # first comment
    hello # ond
    #to be
    solution = { # i'm
        expected = ML, TL #lovin'
        } # it
    solution = { # masha
    possible = A, B, C, D #why?
    #to be
    } # pasha
    #or
    #not
} # korova
"""
        )
        self.assertEqual(
            conf.get_text(),
            """
config = { # first comment
    hello # ond
    #to be
    solution = { # i'm
        expected = ML, TL #lovin'
        # it
    }
    solution = { # masha
        possible = A, B, C, D #why?
        #to be
        # pasha
    }
    #or
    #not
    # korova
}
""",
        )
示例#8
0
    def test_set_solution(self):
        package_config = Config("""please_version = 0.1
my_sister = Liza""")
        for basename in range(5):
            config_file = Config("")
            config_file["source"] = "solutions." + str(basename)
            config_file["expected"] = ["OK"]
            config_file["possible"] = ["ML"]
            package_config.set("solution", config_file, None, True)
        self.assertEqual(
            package_config.get_text(), """please_version = 0.1
my_sister = Liza
solution = {
    source = solutions.0
    expected = OK
    possible = ML
}
solution = {
    source = solutions.1
    expected = OK
    possible = ML
}
solution = {
    source = solutions.2
    expected = OK
    possible = ML
}
solution = {
    source = solutions.3
    expected = OK
    possible = ML
}
solution = {
    source = solutions.4
    expected = OK
    possible = ML
}
""")
示例#9
0
    def test_set_sol(self):
        conf = Config(
            """please = 0.1
input = a.in
output = a.out
"""
        )
        conf2 = Config(
            """expected = ML, TL
possible = OK"""
        )
        conf["solution"] = [conf2]
        self.assertEqual(
            conf.get_text(),
            """please = 0.1
input = a.in
output = a.out
solution = {
    expected = ML, TL
    possible = OK
}
""",
        )
示例#10
0
    def test_set(self):
        conf = Config(
            """
conf = {
solution = {
    expected = ML, TL #cmo
    }
solution = {#abc
    possible = OK
    }#avb
solution = {
    input = "peen"
    }
    
}"""
        )
        conf["conf"].delete("solution", 1)
        conf2 = Config("")
        conf2["expected"] = ["ML", "OK"]
        conf["conf"].set("solution", conf2, None, True)
        self.assertEqual(
            conf.get_text(),
            """
conf = {
    solution = {
        expected = ML, TL #cmo
    }
    solution = {
        input = "peen"
    }
    
    solution = {
        expected = ML, OK
    }
}
""",
        )
示例#11
0
    def test_get_text(self):
        conf = Config("""please_version = 0.1

name = sloniki
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
 # 23
# 23
key = value # 23

#randcomment
memory_limit = 64 """)

        conf["name"] = "slonik"
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
memory_limit = 64
"""

        self.assertEqual(conf.get_text(), text)
        conf["schoolboy"] = "stupid"
        conf["schoolboy"] = "extra stupid"

        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
memory_limit = 64
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)
        del conf["memory_limit"]

        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)

        del conf["time_limit"]
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
#
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)

        conf["abacaba2"] = "z-function"
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
#
abacaba
abacaba1 #
abacaba2 = z-function #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)

        conf["wazzzuuup"] = None
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
#
abacaba
abacaba1 #
abacaba2 = z-function #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
wazzzuuup
"""
        self.assertEqual(conf.get_text(), text)
示例#12
0
    def test_get_text(self):
        conf = Config(
            """please_version = 0.1

name = sloniki
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
 # 23
# 23
key = value # 23

#randcomment
memory_limit = 64 """
        )

        conf["name"] = "slonik"
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
memory_limit = 64
"""

        self.assertEqual(conf.get_text(), text)
        conf["schoolboy"] = "stupid"
        conf["schoolboy"] = "extra stupid"

        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
memory_limit = 64
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)
        del conf["memory_limit"]

        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
time_limit = 1 #
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)

        del conf["time_limit"]
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
#
abacaba
abacaba1 #
abacaba2 #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)

        conf["abacaba2"] = "z-function"
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
#
abacaba
abacaba1 #
abacaba2 = z-function #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
"""
        self.assertEqual(conf.get_text(), text)

        conf["wazzzuuup"] = None
        text = """please_version = 0.1

name = slonik
#dont know tags

input = sloniki.in
output = sloniki.out
#
abacaba
abacaba1 #
abacaba2 = z-function #        23
# 23
# 23
key = value # 23

#randcomment
schoolboy = extra stupid
wazzzuuup
"""
        self.assertEqual(conf.get_text(), text)