-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lang: fixes for invalid detection on class.property, numeric was also…
… taken as a class.property. Closes #34
- Loading branch information
Mathieu Virbel
committed
Feb 10, 2011
1 parent
fcc1c20
commit d05fb26
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
''' | ||
Language tests | ||
============== | ||
''' | ||
|
||
import unittest | ||
|
||
class TestClass(object): | ||
obj = None | ||
|
||
class LangTestCase(unittest.TestCase): | ||
|
||
def import_builder(self): | ||
from kivy.factory import Factory | ||
from kivy.lang import Builder | ||
Factory.register('TestClass', cls=TestClass) | ||
return Builder | ||
|
||
def test_loading_failed_1(self): | ||
# invalid indent | ||
Builder = self.import_builder() | ||
from kivy.lang import ParserError | ||
try: | ||
Builder.load_string('''#:kivy 1.0 | ||
<TestClass>: | ||
''') | ||
self.fail('Invalid indentation.') | ||
except ParserError: | ||
pass | ||
|
||
def test_parser_numeric_1(self): | ||
Builder = self.import_builder() | ||
Builder.load_string('<TestClass>:\n\tobj: (.5, .5, .5)') | ||
wid = TestClass() | ||
Builder.apply(wid) | ||
self.assertEqual(wid.obj, (0.5, 0.5, 0.5)) | ||
|
||
def test_parser_numeric_2(self): | ||
Builder = self.import_builder() | ||
Builder.load_string('<TestClass>:\n\tobj: (0.5, 0.5, 0.5)') | ||
wid = TestClass() | ||
Builder.apply(wid) | ||
self.assertEqual(wid.obj, (0.5, 0.5, 0.5)) | ||
|