Sha256: 9a7d40a4b7e515f9bf1c8d600831a27470e17c0a132876257714a9354a97d238

Contents?: true

Size: 991 Bytes

Versions: 3

Compression:

Stored size: 991 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe Rupy::PythonError do
  include RubyPythonStartStop

  def cause_error
    Rupy::Python.PyImport_ImportModule("wat")
  end

  describe "#error?" do
    it "should return false when no error has occured" do
      described_class.error?.should be_false
    end

    it "should return true when an error has occured" do
      cause_error
      described_class.error?.should be_true
    end
  end

  describe "#clear" do
    it "should reset the Python error flag" do
      cause_error
      described_class.clear
      described_class.error?.should be_false
    end

    it "should not barf when there is no error" do
      lambda {described_class.clear}.should_not raise_exception
    end
  end


  describe "#fetch" do
    it "should make availible Python error type" do
      cause_error
      rbType, rbValue, rbTraceback = described_class.fetch
      rbType.getAttr("__name__").rubify.should == "ImportError"
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rupy-0.4.2 spec/pythonerror_spec.rb
rupy-0.4.1 spec/pythonerror_spec.rb
rupy-0.4.0 ./spec/pythonerror_spec.rb