This file is indexed.

/usr/share/pyshared/martian/edgecase.txt is in python-martian 0.14-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
(Edge-case) tests of Martian core components
============================================

ModuleGrokker ignores values set by directives
----------------------------------------------

Consider the following module-level directive:

  >>> import martian
  >>> class store(martian.Directive):
  ...     scope = martian.MODULE
  ...     store = martian.ONCE
  ...
  >>> store.__module__ = 'somethingelse'  # just so that it isn't __builtin__

Now let's look at a module that contains a simple function and a call
to the directive defined above:

  >>> class module_with_directive(FakeModule):
  ...     fake_module = True
  ...
  ...     def some_function():
  ...         return 11
  ...
  ...     store(some_function)
  ...
  >>> from martiantest.fake import module_with_directive

Now imagine we have the following grokker for functions:

  >>> import types
  >>> class FunctionGrokker(martian.InstanceGrokker):
  ...     martian.component(types.FunctionType)
  ...     def grok(self, name, obj, **kw):
  ...         print name, obj()
  ...         return True
  ...
  >>> module_grokker = martian.ModuleGrokker()
  >>> module_grokker.register(FunctionGrokker())

and let it loose on the module, we see that it will only find functions
set by regular variable assignment, not the ones stored by the
directive:

  >>> module_grokker.grok('module_with_directive', module_with_directive)
  some_function 11
  True

Directive scope and default edge cases
--------------------------------------

  >>> from martian import Directive, CLASS_OR_MODULE, CLASS, MODULE
  >>> from martian import ONCE 

MODULE scope directive on a module, with no explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = MODULE
  ...     store = ONCE  
  >>> class module_no_explicit_value(FakeModule):
  ...     fake_module = True
  >>> from martiantest.fake import module_no_explicit_value
  >>> mydir.bind().get(module_no_explicit_value) is None
  True

MODULE scope directive on a module, with an explicit value::

  >>> class mydir2(martian.Directive):
  ...     scope = MODULE
  ...     store = ONCE  
  >>> class module_with_explicit_value(FakeModule):
  ...     fake_module = True
  ...     mydir2('the explicit value')
  >>> from martiantest.fake import module_with_explicit_value
  >>> mydir2.bind().get(module_with_explicit_value)
  'the explicit value'

MODULE scope directive on a module, with no explicit value, with a custom default::

  >>> class mydir(martian.Directive):
  ...     scope = MODULE
  ...     store = ONCE  
  >>> class module_custom_default(FakeModule):
  ...     fake_module = True
  >>> from martiantest.fake import module_custom_default
  >>> def custom(component, module, **data):
  ...     return 'a custom default value'
  >>> mydir.bind(get_default=custom).get(module_custom_default)
  'a custom default value'
 
CLASS scope directive on a class, with no explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS
  ...     store = ONCE  
  >>> class module_get_from_class_no_explicit(FakeModule):
  ...     class MyClass(object):
  ...         pass
  >>> from martiantest.fake import module_get_from_class_no_explicit
  >>> mydir.bind().get(module_get_from_class_no_explicit.MyClass) is None
  True

CLASS scope directive on an instance, with no explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS
  ...     store = ONCE  
  >>> class module_get_from_instance_no_explicit(FakeModule):
  ...     class MyClass(object):
  ...         pass
  ...     obj = MyClass()
  >>> from martiantest.fake import module_get_from_instance_no_explicit
  >>> mydir.bind().get(module_get_from_instance_no_explicit.obj) is None
  True

CLASS scope directive on a class, with an explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS
  ...     store = ONCE  
  >>> class module_get_from_class_with_explicit(FakeModule):
  ...     class MyClass(object):
  ...         mydir('explicitly set')
  >>> from martiantest.fake import module_get_from_class_with_explicit
  >>> mydir.bind().get(module_get_from_class_with_explicit.MyClass)
  'explicitly set'

CLASS scope directive on an instance, with an explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS
  ...     store = ONCE  
  >>> class module_get_from_instance_with_explicit(FakeModule):
  ...     class MyClass(object):
  ...         mydir('explicitly set')
  ...     obj = MyClass()
  >>> from martiantest.fake import module_get_from_instance_with_explicit
  >>> mydir.bind().get(module_get_from_instance_with_explicit.obj)
  'explicitly set'

CLASS scope directive on a class, with a custom default::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS
  ...     store = ONCE  
  >>> class module_get_from_class_with_custom(FakeModule):
  ...     class MyClass(object):
  ...         pass
  >>> from martiantest.fake import module_get_from_class_with_custom
  >>> def custom_get_default(component, module, **data):
  ...     return 'custom default'
  >>> mydir.bind(get_default=custom_get_default).get(
  ...     module_get_from_class_with_custom.MyClass)
  'custom default'

CLASS scope directive on an instance, with a custom default::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS
  ...     store = ONCE  
  >>> class module_get_from_instance_with_custom(FakeModule):
  ...     class MyClass(object):
  ...         pass
  ...     obj = MyClass()
  >>> from martiantest.fake import module_get_from_instance_with_custom
  >>> mydir.bind(get_default=custom_get_default).get(
  ...     module_get_from_instance_with_custom.obj)
  'custom default'

CLASS_OR_MODULE scope directive on a module, with no explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     pass
  >>> from martiantest.fake import module
  >>> mydir.bind().get(module) is None
  True

CLASS_OR_MODULE scope directive on a class, with no explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     class MyClass(object):
  ...         pass
  >>> from martiantest.fake import module
  >>> mydir.bind().get(module.MyClass) is None
  True

CLASS_OR_MODULE scope directive on an instance, with no explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     class MyClass(object):
  ...         pass
  ...     obj = MyClass()
  >>> from martiantest.fake import module
  >>> mydir.bind().get(module.obj) is None
  True

CLASS_OR_MODULE scope directive on a module, with an explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     mydir('explicitly set, see?')
  >>> from martiantest.fake import module
  >>> mydir.bind().get(module)
  'explicitly set, see?'

CLASS_OR_MODULE scope directive on a class, with an explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     class MyClass(object):
  ...         mydir('explicitly set, see?')
  >>> from martiantest.fake import module
  >>> mydir.bind().get(module.MyClass)
  'explicitly set, see?'

CLASS_OR_MODULE scope directive on an instance, with an explicit value::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     class MyClass(object):
  ...         mydir('explicitly set, see?')
  ...     obj = MyClass()
  >>> from martiantest.fake import module
  >>> mydir.bind().get(module.obj)
  'explicitly set, see?'

CLASS_OR_MODULE scope directive on a module, with a custom default::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  >>> from martiantest.fake import module
  >>> mydir.bind(get_default=custom_get_default).get(module)
  'custom default'

CLASS_OR_MODULE scope directive on a class, with a custom default::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     class MyClass(object):
  ...         pass
  >>> from martiantest.fake import module
  >>> mydir.bind(get_default=custom_get_default).get(module.MyClass)
  'custom default'

CLASS_OR_MODULE scope directive on an instance, with a custom default::

  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE  
  >>> class module(FakeModule):
  ...     fake_module = True
  ...     class MyClass(object):
  ...         pass
  ...     obj = MyClass()
  >>> from martiantest.fake import module
  >>> mydir.bind(get_default=custom_get_default).get(module.obj)
  'custom default'
  
  CLASS_OR_MODULE scope directive on the module, with inheritance::
  
  >>> class mydir(martian.Directive):
  ...     scope = CLASS_OR_MODULE
  ...     store = ONCE
  >>> class module_b(FakeModule):
  ...     fake_module = True
  ...     mydir('a value')
  ...     class B(object):
  ...         pass
  >>> from martiantest.fake import module_b  
  >>> class module_a(FakeModule):
  ...     fake_module = True
  ...     class A(module_b.B):
  ...         pass
  >>> from martiantest.fake import module_a
  >>> mydir.bind(get_default=custom_get_default).get(module_a.A)
  'a value'