<s> from nose . tools import eq_ , ok_ <EOL> import unittest <EOL> import time <EOL> from openxc . measurements import Measurement , VehicleSpeed <EOL> class MeasurementTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( MeasurementTests , self ) . setUp ( ) <EOL> def test_basic ( self ) : <EOL> Measurement ( "<STR_LIT:name>" , "<STR_LIT:value>" , override_unit = True ) <EOL> def test_has_age ( self ) : <EOL> measurement = Measurement ( "<STR_LIT:name>" , "<STR_LIT:value>" , override_unit = True ) <EOL> age = measurement . age <EOL> time . sleep ( <NUM_LIT> ) <EOL> ok_ ( measurement . age > age ) <EOL> def test_unit ( self ) : <EOL> measurement = VehicleSpeed ( <NUM_LIT> , override_unit = True ) <EOL> try : <EOL> eq_ ( measurement . value , <NUM_LIT> ) <EOL> except AttributeError : <EOL> pass <EOL> else : <EOL> self . fail ( ) <EOL> eq_ ( measurement . value , measurement . unit ( <NUM_LIT> ) ) <EOL> def test_override_unit ( self ) : <EOL> try : <EOL> VehicleSpeed ( <NUM_LIT> ) <EOL> except AttributeError : <EOL> pass <EOL> else : <EOL> self . fail ( ) <EOL> VehicleSpeed ( <NUM_LIT> , override_unit = True ) <EOL> def test_assign_value ( self ) : <EOL> measurement = VehicleSpeed ( <NUM_LIT> , override_unit = True ) <EOL> new_value = VehicleSpeed . unit ( <NUM_LIT> ) <EOL> try : <EOL> measurement . value = <NUM_LIT> <EOL> except AttributeError : <EOL> eq_ ( measurement . value , new_value ) <EOL> else : <EOL> self . fail ( ) <EOL> measurement . value = new_value <EOL> eq_ ( measurement . value , new_value ) </s>
