~cjwatson/xorgparser/python3

« back to all changes in this revision

Viewing changes to tests/1-test.py

  • Committer: Alberto Milone
  • Date: 2010-04-20 09:41:29 UTC
  • Revision ID: alberto.milone@canonical.com-20100420094129-k242bip0t8z7xc6x
Tags: 0.4.2.2

* Release 0.4.2.2:
  + xutils.py:
    - make isDriverInSection() return True only if all of the specified
      sections contain the driver. This prevents isDriverEnabled() from
      returning false positives.
  + 1-test.py:
    - Modify the test for testIsDriverEnabled() so as to test the correct
      behaviour.
    - Add two more tests for IsDriverEnabled().

Show diffs side-by-side

added added

removed removed

Lines of Context:
628
628
        
629
629
        self.failUnless(len(devices) == 2, 'Only 2 Device sections should be found!')
630
630
 
631
 
    def testIsDriverEnabled(self):
 
631
    def testIsDriverEnabled1(self):
632
632
        '''
633
 
        isDriverEnabled(self, driver)
 
633
        isDriverEnabled1(self, driver)
634
634
        '''
635
635
        self.this_function_name = sys._getframe().f_code.co_name
636
636
        
687
687
        self.parser = xutils.XUtils(tempFile)
688
688
        enabled = self.parser.isDriverEnabled('foo')
689
689
        
 
690
        self.failUnless(enabled == False, 'The driver should not be enabled!')
 
691
        
 
692
        enabled = self.parser.isDriverEnabled('bar')
 
693
        self.failUnless(enabled == False, 'The driver should not be enabled!')
 
694
        
 
695
    def testIsDriverEnabled2(self):
 
696
        '''
 
697
        isDriverEnabled2(self, driver)
 
698
        '''
 
699
        self.this_function_name = sys._getframe().f_code.co_name
 
700
        
 
701
        confFile = open(tempFile, 'w')
 
702
        print >> confFile, '''
 
703
Section "Device"
 
704
    Identifier "Default Video Device"
 
705
    Driver "foo"
 
706
EndSection
 
707
 
 
708
Section "Device"
 
709
    Identifier "Another Video Device"
 
710
    Driver "bar"
 
711
EndSection
 
712
'''
 
713
        confFile.close()
 
714
        self.parser = xutils.XUtils(tempFile)
 
715
        enabled = self.parser.isDriverEnabled('foo')
 
716
        
 
717
        self.failUnless(enabled == False, 'The driver should not be enabled!')
 
718
        
 
719
        enabled = self.parser.isDriverEnabled('bar')
 
720
        self.failUnless(enabled == False, 'The driver should not be enabled!')
 
721
 
 
722
    def testIsDriverEnabled3(self):
 
723
        '''
 
724
        isDriverEnabled3(self, driver)
 
725
        '''
 
726
        self.this_function_name = sys._getframe().f_code.co_name
 
727
        
 
728
        confFile = open(tempFile, 'w')
 
729
        print >> confFile, '''
 
730
Section "Device"
 
731
    Identifier "Default Video Device"
 
732
    Driver "foo"
 
733
EndSection
 
734
 
 
735
Section "Device"
 
736
    Identifier "Another Video Device"
 
737
    Driver "foo"
 
738
EndSection
 
739
 
 
740
Section "Device"
 
741
    Identifier "Yet Another Video Device"
 
742
    Driver "bar"
 
743
EndSection
 
744
 
 
745
Section "Screen"
 
746
    Identifier "Default Screen Device"
 
747
    Device "Default Video Device"
 
748
EndSection
 
749
 
 
750
Section "Screen"
 
751
    Identifier "New Screen Device"
 
752
    Device "Yet Another Video Device"
 
753
EndSection
 
754
 
 
755
Section "Screen"
 
756
    Identifier "Another Screen Device"
 
757
    Device "Another Video Device"
 
758
EndSection
 
759
 
 
760
Section "ServerLayout"
 
761
    Identifier "A Layout"
 
762
    Option "Whatever"
 
763
    Screen "Default Screen Device" 0 0
 
764
    Screen "Another Screen Device" RightOf "Default Screen Device"
 
765
EndSection
 
766
'''
 
767
        confFile.close()
 
768
        self.parser = xutils.XUtils(tempFile)
 
769
        enabled = self.parser.isDriverEnabled('foo')
 
770
        
690
771
        self.failUnless(enabled == True, 'The driver should be enabled!')
691
772
        
692
 
        enabled = self.parser.isDriverEnabled('foobar')
 
773
        enabled = self.parser.isDriverEnabled('bar')
693
774
        self.failUnless(enabled == False, 'The driver should not be enabled!')
694
 
        
695
775
 
696
776
    def testGetScreenDeviceRelationships(self):
697
777
        '''