Example #1
0
def check_caching(beam_type_id, mode, order):
    beam_type = BaseBeamType.coerce(beam_type_id)  #@UndefinedVariable

    # Cached derivative should be equal to a freshly computed derivative
    cached_derivative = beam_type.Y_m_derivative_from_cache(mode, order)
    eq_(cached_derivative, diff(beam_type.Y_m(mode), y, order))

    # Continuous cache hits should return same objects
    cache_hit = beam_type.Y_m_derivative_from_cache(mode, order)
    assert_is(cache_hit, cached_derivative)
def test_integrate_options():
    integral = BaseIntegral.coerce(1)  #@UndefinedVariable
    beam_type = BaseBeamType.coerce(1)  #@UndefinedVariable

    def base_integrate(**kwargs):
        return integrate(integral,
                         beam_type,
                         a=1.,
                         m=1,
                         n=1,
                         decimal_precision=tests.DECIMAL_PRECISION,
                         **kwargs)

    # When called with `error=True` `integrate` should return a `(result, error)` tuple
    result_with_error_info = base_integrate(error=True)
    assert_is(type(result_with_error_info), tuple)

    # `integrate` should return the same `result` regardless of the `error` flag
    assert_equal(base_integrate(), result_with_error_info[0])
Example #3
0
 def test_cached_find_best_root_returns_same_objects(self):
     self.regenerate_cache()
     
     cache_hit_1 = self.find_best_root()
     cache_hit_2 = self.find_best_root()
     assert_is(cache_hit_1, cache_hit_2)
Example #4
0
 def test_coerce_valid_http_response_id(self):
     assert_is(
         self.HttpResponse.coerce(self.actual_http_response_class.status_code),
         self.desired_http_response_instance
     )
Example #5
0
 def test_coerce_nonnumeric_id(self):
     assert_is(
         self.HTTPMethod.coerce(self.actual_http_method_id),
         self.desired_http_method_instance
     )
Example #6
0
 def test_coerce_valid_http_response_class(self):
     assert_is(
         type(self.HttpResponse.coerce(self.actual_http_response_class)),
         self.desired_http_response_class
     )
Example #7
0
 def test_parent_uses_same_plugin_info_cache_as_base_class(self):
     self.POST._plugins = None
     self.HTTPMethod._plugins = None
     assert_is(self.POST.plugins, self.HTTPMethod.plugins)
Example #8
0
 def test_child_uses_same_plugin_info_cache_as_parent(self):
     self.FakePOST._plugins = None
     self.POST._plugins = None
     assert_is(self.FakePOST.plugins, self.POST.plugins)
Example #9
0
 def test_distant_relatives_use_same_plugin_info_cache(self):
     self.GET._plugins = None
     self.POST._plugins = None
     assert_is(self.GET.plugins, self.POST.plugins)
Example #10
0
 def test_contribute_to_plugins(self):
     assert_is(self.HttpResponse.plugins.contribute_to_plugins_works, True)