rubypython 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ describe "RubyPython" do
8
8
  string = cPickle.dumps("Testing RubyPython.")
9
9
  string.should_not be_a_kind_of String
10
10
  string.rubify.should be_a_kind_of String
11
- string.rubify.should == "S'Testing RubyPython.'\np1\n."
11
+ string.rubify.should ~ /S'Testing RubyPython.'\n/
12
12
  end
13
13
 
14
14
  it "can import and use a pure Python extension like pickle" do
@@ -16,7 +16,7 @@ describe "RubyPython" do
16
16
  string = pickle.dumps("Testing RubyPython.")
17
17
  string.should_not be_a_kind_of String
18
18
  string.rubify.should be_a_kind_of String
19
- string.rubify.should == "S'Testing RubyPython.'\np0\n."
19
+ string.rubify.should ~ /S'Testing RubyPython.'\n/
20
20
  end
21
21
 
22
22
  it "can use iterators from Python" do
@@ -120,24 +120,6 @@ describe RubyPython::PyObject do
120
120
  end
121
121
  end
122
122
 
123
- describe "#makeTuple" do
124
- it "should wrap single arguments in a tuple" do
125
- arg = described_class.new AString
126
- described_class.makeTuple(arg).rubify.should == [AString]
127
- end
128
-
129
- it "should turn a Python list into a tuple" do
130
- arg = @objects.a_list.pObject
131
- converted = described_class.makeTuple(arg)
132
- converted.rubify.should == AnArray
133
- end
134
-
135
- it "should return the given argument if it is a tuple" do
136
- arg = @objects.a_tuple.pObject
137
- converted = described_class.makeTuple(arg)
138
- converted.pointer.address.should == arg.pointer.address
139
- end
140
- end
141
123
 
142
124
  describe "#callObject" do
143
125
  #Expand coverage types
@@ -151,15 +133,6 @@ describe RubyPython::PyObject do
151
133
  end
152
134
  end
153
135
 
154
- describe "#newList" do
155
- it "should wrap supplied args in a Python list" do
156
- args = AnArray.map do |obj|
157
- described_class.new obj
158
- end
159
- described_class.newList(*args).rubify.should == AnArray
160
- end
161
- end
162
-
163
136
  describe "#function_or_method?" do
164
137
  it "should be true given a method" do
165
138
  mockObjClass = @objects.RubyPythonMockObject.pObject
@@ -226,21 +199,4 @@ describe RubyPython::PyObject do
226
199
 
227
200
  end
228
201
 
229
- describe ".convert" do
230
- it "should not modify PyObjects passed to it" do
231
- args = AnArray.map { |x| described_class.new(x) }
232
- described_class.convert(*args).should == args
233
- end
234
-
235
- it "should pull PyObjects out of RubyPyProxy instances" do
236
- args = @objects.an_array.to_a
237
- described_class.convert(*args).should == args.map {|x| x.pObject}
238
- end
239
-
240
- it "should create new PyObject instances of simple Ruby types" do
241
- described_class.convert(*AnArray).each do |x|
242
- x.should be_a_kind_of described_class
243
- end
244
- end
245
- end
246
202
  end
@@ -8,8 +8,7 @@ def get_refcnt(pobject)
8
8
  elsif pobject.kind_of? RubyPython::PyObject
9
9
  pobject = pobject.pointer
10
10
  end
11
- struct = RubyPython::Python::PyObjectStruct.new pobject
12
- struct[:ob_refcnt]
11
+ RubyPython::Macros.Py_REFCNT pobject
13
12
  end
14
13
 
15
14
  include TestConstants
@@ -59,4 +58,41 @@ describe 'Reference Counting' do
59
58
  end
60
59
  end
61
60
  end
61
+
62
+ describe RubyPython::Conversion do
63
+ describe ".rtopArrayToList" do
64
+ it "should incref any wrapped objects in the array" do
65
+ int = RubyPython::PyObject.new AnInt
66
+ refcnt = get_refcnt(int)
67
+ arr = [int]
68
+ pyArr = subject.rtopArrayToList(arr)
69
+ get_refcnt(int).should == refcnt + 1
70
+ end
71
+
72
+ end
73
+
74
+ describe ".rtopObject" do
75
+ [
76
+ ["string", AString],
77
+ ["float", AFloat],
78
+ ["array", AnArray],
79
+ #["symbol", ASym],
80
+ ["hash", AHash]
81
+ ].each do |arr|
82
+ type, input = arr
83
+
84
+ it "should return a refcnt of 1 for newly created #{type}" do
85
+ pyObj = subject.rtopObject(input)
86
+ get_refcnt(pyObj).should == 1
87
+ end
88
+
89
+ it "should increment the refcnt each time the same #{type} is passed in" do
90
+ pyObj = RubyPython::PyObject.new subject.rtopObject(input)
91
+ refcnt = get_refcnt(pyObj)
92
+ pyObj2 = subject.rtopObject(pyObj)
93
+ get_refcnt(pyObj2).should == refcnt + 1
94
+ end
95
+ end
96
+ end
97
+ end
62
98
  end
@@ -52,7 +52,7 @@ RSpec.configure do |config|
52
52
  end
53
53
  end
54
54
 
55
- config.before(:all, :self_start => nil) do
55
+ config.before(:all) do
56
56
  RubyPython.start
57
57
 
58
58
  @sys = RubyPython.import 'sys'
@@ -61,6 +61,10 @@ RSpec.configure do |config|
61
61
  @basics = RubyPython.import 'basics'
62
62
  end
63
63
 
64
+ config.before(:all, :self_start => true) do
65
+ RubyPython.stop
66
+ end
67
+
64
68
  config.after(:all) do
65
69
  RubyPython.stop
66
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypython
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -39,22 +39,22 @@ cert_chain:
39
39
  OWdkQjNqVmViN0puVExZK1dsSFd0MnJGVmJlcXY3S3RKbHA3KzR1V01La3pU
40
40
  YlcvdWpkRwpjZ3VKTWlRQ1NPbFVQWnhDV1dNa2pmWmJYdnRTNVZkekpldlNx
41
41
  UT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
42
- date: 2012-05-24 00:00:00.000000000 Z
42
+ date: 2012-09-25 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: ffi
46
- requirement: &70207972655700 !ruby/object:Gem::Requirement
46
+ requirement: &70104953559200 !ruby/object:Gem::Requirement
47
47
  none: false
48
48
  requirements:
49
- - - ~>
49
+ - - ! '>='
50
50
  - !ruby/object:Gem::Version
51
51
  version: 1.0.7
52
52
  type: :runtime
53
53
  prerelease: false
54
- version_requirements: *70207972655700
54
+ version_requirements: *70104953559200
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: blankslate
57
- requirement: &70207972655080 !ruby/object:Gem::Requirement
57
+ requirement: &70104953558540 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
60
  - - ! '>='
@@ -62,10 +62,10 @@ dependencies:
62
62
  version: 2.1.2.3
63
63
  type: :runtime
64
64
  prerelease: false
65
- version_requirements: *70207972655080
65
+ version_requirements: *70104953558540
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: rubyforge
68
- requirement: &70207972653860 !ruby/object:Gem::Requirement
68
+ requirement: &70104953557840 !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
71
71
  - - ! '>='
@@ -73,10 +73,10 @@ dependencies:
73
73
  version: 2.0.4
74
74
  type: :development
75
75
  prerelease: false
76
- version_requirements: *70207972653860
76
+ version_requirements: *70104953557840
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: rdoc
79
- requirement: &70207972652560 !ruby/object:Gem::Requirement
79
+ requirement: &70104953557080 !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements:
82
82
  - - ~>
@@ -84,10 +84,10 @@ dependencies:
84
84
  version: '3.10'
85
85
  type: :development
86
86
  prerelease: false
87
- version_requirements: *70207972652560
87
+ version_requirements: *70104953557080
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: rspec
90
- requirement: &70207972651440 !ruby/object:Gem::Requirement
90
+ requirement: &70104953556240 !ruby/object:Gem::Requirement
91
91
  none: false
92
92
  requirements:
93
93
  - - ~>
@@ -95,10 +95,10 @@ dependencies:
95
95
  version: '2.0'
96
96
  type: :development
97
97
  prerelease: false
98
- version_requirements: *70207972651440
98
+ version_requirements: *70104953556240
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: tilt
101
- requirement: &70207972649980 !ruby/object:Gem::Requirement
101
+ requirement: &70104953555580 !ruby/object:Gem::Requirement
102
102
  none: false
103
103
  requirements:
104
104
  - - ~>
@@ -106,10 +106,10 @@ dependencies:
106
106
  version: '1.0'
107
107
  type: :development
108
108
  prerelease: false
109
- version_requirements: *70207972649980
109
+ version_requirements: *70104953555580
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: hoe
112
- requirement: &70207972648560 !ruby/object:Gem::Requirement
112
+ requirement: &70104953570780 !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
115
  - - ~>
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
- version_requirements: *70207972648560
120
+ version_requirements: *70104953570780
121
121
  description: ! 'RubyPython is a bridge between the Ruby and Python interpreters. It
122
122
  embeds a
123
123
 
@@ -166,7 +166,6 @@ files:
166
166
  - lib/rubypython/blankobject.rb
167
167
  - lib/rubypython/conversion.rb
168
168
  - lib/rubypython/interpreter.rb
169
- - lib/rubypython/legacy.rb
170
169
  - lib/rubypython/macros.rb
171
170
  - lib/rubypython/operators.rb
172
171
  - lib/rubypython/pygenerator.rb
@@ -180,7 +179,6 @@ files:
180
179
  - spec/basic_spec.rb
181
180
  - spec/callback_spec.rb
182
181
  - spec/conversion_spec.rb
183
- - spec/legacy_spec.rb
184
182
  - spec/pymainclass_spec.rb
185
183
  - spec/pyobject_spec.rb
186
184
  - spec/python_helpers/basics.py
metadata.gz.sig CHANGED
Binary file
@@ -1,18 +0,0 @@
1
- require 'rubypython'
2
-
3
- # A quick way to activate <em>Legacy Mode</em> for a project. Requiring
4
- # +'rubypython/legacy' automatically activates +RubyPython.legacy_mode+ on
5
- # the project. This mode is deprecated and will be removed.
6
- module RubyPython::LegacyMode
7
- # Enables +RubyPython.legacy_mode+.
8
- def self.setup_legacy
9
- RubyPython.legacy_mode = true
10
- end
11
-
12
- # Disables +RubyPython.legacy_mode+.
13
- def self.teardown_legacy
14
- RubyPython.legacy_mode = false
15
- end
16
- end
17
-
18
- RubyPython::LegacyMode.setup_legacy
@@ -1,46 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- include TestConstants
4
-
5
- describe 'RubyPython Legacy Mode Module' do
6
- before :all do
7
- require 'rubypython/legacy'
8
- end
9
-
10
- after :all do
11
- RubyPython::LegacyMode.teardown_legacy
12
- end
13
-
14
- describe "when required" do
15
- it "should enable legacy mode" do
16
- RubyPython.legacy_mode.should == true
17
- end
18
-
19
- [
20
- ["an int", "an int", AnInt],
21
- ["a float", "a float", AFloat],
22
- ["a string", "a string", AString],
23
- ["a list", "an array", AnArray],
24
- ["a tuple", "an array", AnArray],
25
- ["a dict", "a hash", AConvertedHash],
26
- ["python True", "true", true],
27
- ["python False", "false", false],
28
- ["python None", "nil", nil]
29
- ].each do |py_type, rb_type, output|
30
- it "implicitly converts #{py_type} to #{rb_type}" do
31
- @objects.__send__(py_type.sub(' ', '_')).should == output
32
- end
33
- end
34
-
35
- [
36
- ["proc", AProc],
37
- ["method", AMethod]
38
- ].each do |rb_type, rb_obj|
39
- it "raises an exception if a #{rb_type} callback is supplied" do
40
- lambda do
41
- @objects.apply_callback(rb_obj, [1, 1])
42
- end.should raise_exception(RubyPython::Conversion::UnsupportedConversion)
43
- end
44
- end
45
- end
46
- end