コード例 #1
0
    def test_above_freezing_at_zero(self):
        """Test a temperature that is at freezing."""

        expected = False
        actual = temperature.above_freezing(0)
        self.assertEqual(expected, actual,
                         "The temperature is at the freezing mark.")
コード例 #2
0
    def test_above_freezing_above(self):
        """Test a temperature that is above freezing."""

        expected = True
        actual = temperature.above_freezing(5.2)
        self.assertEqual(expected, actual,
                         "The temperature is above freezing.")
コード例 #3
0
    def test_above_freezing_above(self):
        """어떤 온도가 어는점보다 높은지 테스트한다."""

        expected = True
        actual = temperature.above_freezing(5.2)
        self.assertEqual(expected, actual,
                         "The temperature is above freezing.")
コード例 #4
0
    def test_above_freezing_below(self):
        """Test a temperature that is below freezing."""

        expected = False
        actual = temperature.above_freezing(-2)
        self.assertEqual(expected, actual,
                         "The temperature is below freezing.")
コード例 #5
0
    def test_above_freezing_at_zero(self):
        """어떤 온도가 어는점과 같은지 테스트한다."""

        expected = False
        actual = temperature.above_freezing(0)
        self.assertEqual(expected, actual,
                         "The temperature is at the freezing mark.")
コード例 #6
0
    def test_above_freezing_below(self):
        """어떤 온도가 어는점보다 낮은지 테스트한다."""

        expected = False
        actual = temperature.above_freezing(-2)
        self.assertEqual(expected, actual,
                         "The temperature is below freezing.")
コード例 #7
0
def test_above_freezing():  # 测试函数的名称也必须以“test”开头。
    print '''Test above_freezing '''
    assert above_freezing(89.4), 'A temperature above freezing'
    assert not above_freezing(-42), 'A temperature below freezing'
    assert not above_freezing(0), 'A temperature at freezing'
コード例 #8
0
ファイル: PP_Ch_06_B.py プロジェクト: hazza1999/ECP3004S21
...
    convert_to_celsius(75)
    23.88888888888889
    """
    return (fahrenheit - 32.0) * 5.0 / 9.0
...

 

# If you save this function definition into a file names
# temperature.py, you can import it as a module. 

 
import temperature
celsius = temperature.convert_to_celsius(33.3)
temperature.above_freezing(celsius)
# True

 



#-------------------------------------------------
### What Happens During Import
#-------------------------------------------------

# Let's try an experiment: save the following command in a file 
# called experiment.py. 

 
print("The panda's scientific name is 'Ailuropoda melanoleuca'")
コード例 #9
0
def test_above_freezing ():
	'''Test above_freezing '''
	assert above_freezing(89.4), 'A temperature above freezing'
	assert not above_freezing(-42), 'A temperature below freezing'
	assert not above_freezing(0), 'A temperature at freezing'
コード例 #10
0
def test_above_freezing():
    '''Test above_freezing '''
    assert above_freezing(89.4), 'A temperature above freezing'
    assert not above_freezing(-42), 'A temperature below freezing'
    assert not above_freezing(0), 'A temperature at freezing'
コード例 #11
0
    def test_above_freezing_above(self):
        """Test a temperature that is above freezing."""

        expected = True
        actual = temperature.above_freezing(5.2)
        self.assertEqual(expected, actual, "The temperature is above freezing.")
コード例 #12
0
    def test_above_freezing_at_zero(self):
        """Test a temperature that is at freezing."""

        expected = False
        actual = temperature.above_freezing(0)
        self.assertEqual(expected, actual, "The temperature is at the freezing mark.")
コード例 #13
0
    def test_above_freezing_below(self):
        """Test a temperature that is below freezing."""

        expected = False
        actual = temperature.above_freezing(-2)
        self.assertEqual(expected, actual, "The temperature is below freezing.")